Permalink
Browse files

Move reticule button enable/disable control into scripts.

New qtscript features:
- setReticuleFlash(id, value) - make reticule button flash
- levelType - read type of level (set in .lev file)
  • Loading branch information...
perim committed Nov 29, 2017
1 parent 8c9e726 commit 2810c730e1733262b3ff27decfbb93c1db821a6a
View
@@ -3,6 +3,57 @@
// * Enable unit design and minimap only when an HQ exists
receiveAllEvents(true); //Needed to allow enemy research to apply to them
var mainReticule = true;
var allowDesign = false;
function setMainReticule()
{
setReticuleButton(0, _("Close"), "image_cancel_up.png", "image_cancel_down.png");
if (countStruct("A0LightFactory") + countStruct("A0CyborgFactory") + countStruct("A0VTolFactory1") > 0
&& levelType != LDS_EXPAND_LIMBO)
{
setReticuleButton(1, _("Manufacture (F1)"), "image_manufacture_up.png", "image_manufacture_down.png");
}
else
{
setReticuleButton(1, _("Manufacture - build factory first"), "", "");
}
if (countStruct("A0ResearchFacility") > 0 && levelType != LDS_EXPAND_LIMBO)
{
setReticuleButton(2, _("Research (F2)"), "image_research_up.png", "image_research_down.png");
}
else
{
setReticuleButton(2, _("Research - build research facility first"), "", "");
}
if (countDroid(DROID_CONSTRUCT, selectedPlayer) > 0)
{
setReticuleButton(3, _("Build (F3)"), "image_build_up.png", "image_build_down.png");
}
else
{
setReticuleButton(3, _("Build - manufacture constructor droids first"), "", "");
}
if (allowDesign == true)
{
setReticuleButton(4, _("Design (F4)"), "image_design_up.png", "image_design_down.png");
}
else
{
setReticuleButton(4, _("Design - construct HQ first"), "", "");
}
setReticuleButton(5, _("Intelligence Display (F5)"), "image_intelmap_up.png", "image_intelmap_down.png");
if (countDroid(DROID_COMMAND, selectedPlayer) > 0)
{
setReticuleButton(6, _("Commanders (F6)"), "image_commanddroid_up.png", "image_commanddroid_down.png");
}
else
{
setReticuleButton(6, _("Commanders - manufacture commanders first"), "", "");
}
mainReticule = true; // main reticule window is open
}
function setupGame()
{
if (tilesetType == "URBAN")
@@ -29,6 +80,7 @@ function setupGame()
setReticuleButton(4, _("Design (F4)"), "image_design_up.png", "image_design_down.png");
setReticuleButton(5, _("Intelligence Display (F5)"), "image_intelmap_up.png", "image_intelmap_down.png");
setReticuleButton(6, _("Commanders (F6)"), "image_commanddroid_up.png", "image_commanddroid_down.png");
setMainReticule();
showInterface();
}
@@ -123,23 +175,75 @@ function eventStartLevel()
resetPower();
}
function eventDroidBuilt(droid, structure)
{
var update_reticule = false;
if (droid.player == selectedPlayer && droid.type == DROID
&& (droid.droidType == DROID_CONSTRUCT || droid.droidType == DROID_COMMAND))
{
update_reticule = true;
}
if (mainReticule && update_reticule)
{
setMainReticule();
}
}
function eventStructureBuilt(struct)
{
var update_reticule = false;
if (struct.player == selectedPlayer && struct.type == STRUCTURE && struct.stattype == HQ)
{
// Enable unit design and minimap when an HQ gets built
setMiniMap(true);
setDesign(true);
setMiniMap(true); // show minimap
setDesign(true); // permit designs
allowDesign = true;
update_reticule = true;
}
if (struct.player == selectedPlayer && struct.type == STRUCTURE
&& (struct.stattype == RESEARCH_LAB || struct.stattype == CYBORG_FACTORY
|| struct.stattype == VTOL_FACTORY || struct.stattype == FACTORY))
{
update_reticule = true;
}
if (mainReticule && update_reticule)
{
setMainReticule();
}
}
function eventDestroyed(victim)
{
if (victim.player == selectedPlayer && victim.type == STRUCTURE && victim.stattype == HQ)
var update_reticule = false;
if (victim.player == selectedPlayer && victim.type == STRUCTURE && victim.stattype == HQ && !enumStruct(selectedPlayer, HQ).length)
{
setMiniMap(false); // hide minimap if HQ is destroyed and no other HQs are present
setDesign(false); // and disallow design
allowDesign = false;
update_reticule = true;
}
if (victim.player == selectedPlayer && victim.type == STRUCTURE
&& (victim.stattype == RESEARCH_LAB || victim.stattype == CYBORG_FACTORY
|| victim.stattype == VTOL_FACTORY || victim.stattype == FACTORY))
{
update_reticule = true;
}
if (victim.player == selectedPlayer && victim.type == DROID
&& (victim.droidType == DROID_CONSTRUCT || victim.droidType == DROID_COMMAND))
{
update_reticule = true;
}
if (mainReticule && update_reticule)
{
// Disable unit design and minimap when the HQ gets destroyed
setMiniMap(false);
setDesign(false);
setMainReticule();
}
}
@@ -7,12 +7,6 @@ function eventGameInit()
replaceTexture("page-9-player-buildings-bases.png", "page-9-player-buildings-bases-rockies.png");
setSky("texpages/page-25-sky-urban.png", 0.5, 10000.0);
setReticuleButton(0, _("Close"), "image_cancel_up.png", "image_cancel_down.png");
setReticuleButton(1, _("Manufacture (F1)"), "image_manufacture_up.png", "image_manufacture_down.png");
setReticuleButton(2, _("Research (F2)"), "image_research_up.png", "image_research_down.png");
setReticuleButton(3, _("Build (F3)"), "image_build_up.png", "image_build_down.png");
setReticuleButton(4, _("Design (F4)"), "image_design_up.png", "image_design_down.png");
setReticuleButton(5, _("Intelligence Display (F5)"), "image_intelmap_up.png", "image_intelmap_down.png");
setReticuleButton(6, _("Commanders (F6)"), "image_commanddroid_up.png", "image_commanddroid_down.png");
}
function eventStartLevel()
@@ -11,16 +11,54 @@ receiveAllEvents(true); // If doing this in eventGameInit, it seems to be too l
var lastHitTime = 0;
var cheatmode = false;
var maxOilDrums = 0;
var mainReticule = true;
var allowDesign = false;
function setMainReticule()
{
setReticuleButton(0, _("Close"), "image_cancel_up.png", "image_cancel_down.png");
setReticuleButton(1, _("Manufacture (F1)"), "image_manufacture_up.png", "image_manufacture_down.png");
setReticuleButton(2, _("Research (F2)"), "image_research_up.png", "image_research_down.png");
setReticuleButton(3, _("Build (F3)"), "image_build_up.png", "image_build_down.png");
setReticuleButton(4, _("Design (F4)"), "image_design_up.png", "image_design_down.png");
if (countStruct("A0LightFactory") + countStruct("A0CyborgFactory") + countStruct("A0VTolFactory1") > 0)
{
setReticuleButton(1, _("Manufacture (F1)"), "image_manufacture_up.png", "image_manufacture_down.png");
}
else
{
setReticuleButton(1, _("Manufacture - build factory first"), "", "");
}
if (countStruct("A0ResearchFacility") > 0)
{
setReticuleButton(2, _("Research (F2)"), "image_research_up.png", "image_research_down.png");
}
else
{
setReticuleButton(2, _("Research - build research facility first"), "", "");
}
if (countDroid(DROID_CONSTRUCT, selectedPlayer) > 0)
{
setReticuleButton(3, _("Build (F3)"), "image_build_up.png", "image_build_down.png");
}
else
{
setReticuleButton(3, _("Build - manufacture constructor droids first"), "", "");
}
if (allowDesign == true)
{
setReticuleButton(4, _("Design (F4)"), "image_design_up.png", "image_design_down.png");
}
else
{
setReticuleButton(4, _("Design - construct HQ first"), "", "");
}
setReticuleButton(5, _("Intelligence Display (F5)"), "image_intelmap_up.png", "image_intelmap_down.png");
setReticuleButton(6, _("Commanders (F6)"), "image_commanddroid_up.png", "image_commanddroid_down.png");
if (countDroid(DROID_COMMAND, selectedPlayer) > 0)
{
setReticuleButton(6, _("Commanders (F6)"), "image_commanddroid_up.png", "image_commanddroid_down.png");
}
else
{
setReticuleButton(6, _("Commanders - manufacture commanders first"), "", "");
}
mainReticule = true; // main reticule window is open
}
function setupGame()
@@ -223,6 +261,7 @@ function eventGameInit()
// Disabled by default
setMiniMap(false);
setDesign(false);
allowDesign = false;
// This is the only template that should be enabled before design is allowed
enableTemplate("ConstructionDroid");
@@ -319,21 +358,75 @@ function eventAttacked(victimObj, attackerObj)
}
}
function eventDroidBuilt(droid, structure)
{
var update_reticule = false;
if (droid.player == selectedPlayer && droid.type == DROID
&& (droid.droidType == DROID_CONSTRUCT || droid.droidType == DROID_COMMAND))
{
update_reticule = true;
}
if (mainReticule && update_reticule)
{
setMainReticule();
}
}
function eventStructureBuilt(struct)
{
var update_reticule = false;
if (struct.player == selectedPlayer && struct.type == STRUCTURE && struct.stattype == HQ)
{
setMiniMap(true); // show minimap
setDesign(true); // permit designs
allowDesign = true;
update_reticule = true;
}
if (struct.player == selectedPlayer && struct.type == STRUCTURE
&& (struct.stattype == RESEARCH_LAB || struct.stattype == CYBORG_FACTORY
|| struct.stattype == VTOL_FACTORY || struct.stattype == FACTORY))
{
update_reticule = true;
}
if (mainReticule && update_reticule)
{
setMainReticule();
}
}
function eventDestroyed(victim)
{
var update_reticule = false;
if (victim.player == selectedPlayer && victim.type == STRUCTURE && victim.stattype == HQ && !enumStruct(selectedPlayer, HQ).length)
{
setMiniMap(false); // hide minimap if HQ is destroyed and no other HQs are present
setDesign(false); // and disallow design
allowDesign = false;
update_reticule = true;
}
if (victim.player == selectedPlayer && victim.type == STRUCTURE
&& (victim.stattype == RESEARCH_LAB || victim.stattype == CYBORG_FACTORY
|| victim.stattype == VTOL_FACTORY || victim.stattype == FACTORY))
{
update_reticule = true;
}
if (victim.player == selectedPlayer && victim.type == DROID
&& (victim.droidType == DROID_CONSTRUCT || victim.droidType == DROID_COMMAND))
{
update_reticule = true;
}
if (mainReticule && update_reticule)
{
setMainReticule();
}
}
View
@@ -76,6 +76,12 @@ void W_BUTTON::setFlash(bool enable)
}
}
void W_BUTTON::unlock()
{
dirty = true;
state &= ~(WBUT_LOCK | WBUT_CLICKLOCK);
}
void W_BUTTON::setState(unsigned newState)
{
ASSERT(!((newState & WBUT_LOCK) && (newState & WBUT_CLICKLOCK)), "Cannot have both WBUT_LOCK and WBUT_CLICKLOCK");
View
@@ -63,6 +63,7 @@ class W_BUTTON : public WIDGET
QString getString() const;
void setString(QString string);
void setTip(QString string);
void unlock();
void setImages(Images const &images);
void setImages(Image image, Image imageDown, Image imageHighlight, Image imageDisabled = Image());
Oops, something went wrong.

0 comments on commit 2810c73

Please sign in to comment.