2022-07-10 06:24:30 -07:00
|
|
|
class VhtEvents : StaticEventHandler {
|
2022-07-10 08:20:24 -07:00
|
|
|
ui bool m_useQuestLog;
|
|
|
|
ui string m_questLog;
|
2022-07-10 06:24:30 -07:00
|
|
|
VhtFnPlayerInv m_fGetQuests;
|
|
|
|
VhtQuestHolder vhtGetQuests() const {
|
|
|
|
return m_fGetQuests.vhtRun() ? VhtQuestHolder(m_fGetQuests.m_result) : null;
|
|
|
|
}
|
|
|
|
override void playerEntered(PlayerEvent e) {
|
|
|
|
let p = players[e.playerNumber].mo;
|
|
|
|
if(p && !p.findInventory("VhtQuestHolder")) {
|
|
|
|
p.giveInventoryType("VhtQuestHolder");
|
|
|
|
}
|
|
|
|
if(!m_fGetQuests) {
|
|
|
|
m_fGetQuests = new("VhtFnPlayerInvExist").vhtInit("VhtQuestHolder");
|
|
|
|
}
|
|
|
|
let qh = vhtGetQuests();
|
|
|
|
if(!e.isReturn && m_fGetQuests.m_player == e.playerNumber) {
|
|
|
|
qh.vhtAddQuest("VhtQuest" .. level.levelNum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
override void playerDisconnected(PlayerEvent e) {
|
|
|
|
let p = players[e.playerNumber].mo;
|
|
|
|
if(p) {
|
2022-07-10 07:48:13 -07:00
|
|
|
let qh_ply = VhtQuestHolder(p.findInventory("VhtQuestHolder"));
|
|
|
|
let qh_cur = vhtGetQuests();
|
|
|
|
if(qh_cur == qh_ply) {
|
|
|
|
p.removeInventory(qh_ply);
|
|
|
|
qh_cur = vhtGetQuests();
|
|
|
|
qh_ply.m_quests.move(qh_cur.m_quests);
|
2022-07-10 06:24:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-10 08:20:24 -07:00
|
|
|
override void uiTick() {
|
2022-07-10 06:24:30 -07:00
|
|
|
m_useQuestLog = vht_player_questlog;
|
2022-07-10 08:20:24 -07:00
|
|
|
if(m_useQuestLog) {
|
|
|
|
let qh = vhtGetQuests();
|
|
|
|
if(qh) {
|
|
|
|
m_questLog = qh.vhtDescribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
override void worldTick() {
|
2022-07-10 06:24:30 -07:00
|
|
|
let qh = vhtGetQuests();
|
2022-07-10 07:48:13 -07:00
|
|
|
if(qh) {
|
|
|
|
qh.vhtTick();
|
2022-07-10 06:24:30 -07:00
|
|
|
}
|
|
|
|
}
|
2022-07-10 10:30:33 -07:00
|
|
|
override void worldLineActivated(WorldEvent e) {
|
|
|
|
if(vht_player_scruteswitch) {
|
|
|
|
let which = "VHT_SWI_" .. level.levelNum .. "_" .. e.activatedLine.index();
|
|
|
|
let loc = StringTable.localize(which, false);
|
|
|
|
if(loc != which) {
|
|
|
|
Console.midPrint(null, loc, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-10 06:24:30 -07:00
|
|
|
override void renderUnderlay(RenderEvent e) {
|
|
|
|
if(automapActive && m_useQuestLog) {
|
|
|
|
double x = Screen.getWidth() / 320.0;
|
|
|
|
double y = Screen.getHeight() / 8.0;
|
|
|
|
Screen.drawText(smallfont, Font.CR_UNTRANSLATED, x+x, y+x, m_questLog, DTA_CLEANNOMOVE_1,true, DTA_ALPHA,0.406, DTA_FILLCOLOR,0);
|
|
|
|
Screen.drawText(smallfont, Font.CR_UNTRANSLATED, x, y, m_questLog, DTA_CLEANNOMOVE_1,true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|