Skip to content

Commit

Permalink
qtscript: Add more missing pieces for tutorial.
Browse files Browse the repository at this point in the history
New events: eventDesignBody, eventDesignPropulsion,
eventDesignWeapon, eventDesignCommand, eventDesignSystem,
eventDesignQuit, eventMenuBuildSelected, eventMenuBuild,
eventMenuResearch, and eventMenuManufacture.
  • Loading branch information
perim committed Dec 2, 2017
1 parent 2810c73 commit 629d437
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/design.cpp
Expand Up @@ -3133,6 +3133,7 @@ void intProcessDesign(UDWORD id)
{
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DESIGN_WEAPON);
}
triggerEvent(TRIGGER_DESIGN_WEAPON);
break;
//Added cases for 2nd/3rd turret
case IDES_TURRET_A:
Expand Down Expand Up @@ -3166,6 +3167,7 @@ void intProcessDesign(UDWORD id)
{
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DESIGN_WEAPON);
}
triggerEvent(TRIGGER_DESIGN_WEAPON);
break;
case IDES_TURRET_B:
/* Calculate the index of the component */
Expand All @@ -3189,6 +3191,7 @@ void intProcessDesign(UDWORD id)
{
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DESIGN_WEAPON);
}
triggerEvent(TRIGGER_DESIGN_WEAPON);
break;
case IDES_BODY:
/* reveal propulsion button if hidden */
Expand Down Expand Up @@ -3251,6 +3254,7 @@ void intProcessDesign(UDWORD id)
{
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DESIGN_BODY);
}
triggerEvent(TRIGGER_DESIGN_BODY);
break;
case IDES_PROPULSION:
/* Calculate the index of the component */
Expand Down Expand Up @@ -3288,6 +3292,7 @@ void intProcessDesign(UDWORD id)
{
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DESIGN_PROPULSION);
}
triggerEvent(TRIGGER_DESIGN_PROPULSION);
break;
default:
break;
Expand Down Expand Up @@ -3458,6 +3463,14 @@ void intProcessDesign(UDWORD id)
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DESIGN_SYSTEM);
}
}
if (apsExtraSysList[id - IDDES_EXTRASYSSTART]->compType == COMP_BRAIN)
{
triggerEvent(TRIGGER_DESIGN_COMMAND);
}
else
{
triggerEvent(TRIGGER_DESIGN_SYSTEM);
}
}
else
{
Expand Down
21 changes: 20 additions & 1 deletion src/hci.cpp
Expand Up @@ -907,6 +907,7 @@ void intResetScreen(bool NoAnim)
{
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DESIGN_QUIT);
}
triggerEvent(TRIGGER_DESIGN_QUIT);
break;
case INT_INTELMAP:
if (NoAnim)
Expand Down Expand Up @@ -2160,9 +2161,12 @@ static void intProcessStats(UDWORD id)
// call the tutorial callback if necessary
if (bInTutorial && objMode == IOBJ_BUILD)
{

eventFireCallbackTrigger((TRIGGER_TYPE)CALL_BUILDGRID);
}
if (objMode == IOBJ_BUILD)
{
triggerEvent(TRIGGER_MENU_BUILD_SELECTED);
}

// Set the object stats
compIndex = id - IDSTAT_START;
Expand Down Expand Up @@ -3809,6 +3813,21 @@ static bool intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats,
}
}

switch (objMode)
{
case IOBJ_BUILD:
triggerEvent(TRIGGER_MENU_BUILD_UP);
break;
case IOBJ_RESEARCH:
triggerEvent(TRIGGER_MENU_RESEARCH_UP);
break;
case IOBJ_MANUFACTURE:
triggerEvent(TRIGGER_MENU_MANUFACTURE_UP);
break;
default:
break;
}

return true;
}

Expand Down
53 changes: 53 additions & 0 deletions src/qtscript.cpp
Expand Up @@ -986,6 +986,26 @@ void jsShowDebug()
//__ An event that is run when the mission transporter has no more reinforcements to deliver.
//__ \subsection{eventTransporterLanded(transport)}
//__ An event that is run when the mission transporter has landed with reinforcements.
//__ \subsection{eventDesignBody()}
//__An event that is run when current user picks a body in the design menu.
//__ \subsection{eventDesignPropulsion()}
//__An event that is run when current user picks a propulsion in the design menu.
//__ \subsection{eventDesignWeapon()}
//__An event that is run when current user picks a weapon in the design menu.
//__ \subsection{eventDesignCommand()}
//__An event that is run when current user picks a command turret in the design menu.
//__ \subsection{eventDesignSystem()}
//__An event that is run when current user picks a system other than command turret in the design menu.
//__ \subsection{eventDesignQuit()}
//__An event that is run when current user leaves the design menu.
//__ \subsection{eventMenuBuildSelected()}
//__An event that is run when current user picks something new in the build menu.
//__ \subsection{eventMenuBuild()}
//__An event that is run when current user opens the build menu.
//__ \subsection{eventMenuResearch()}
//__An event that is run when current user opens the research menu.
//__ \subsection{eventMenuManufacture()}
//__An event that is run when current user opens the manufacture menu.
bool triggerEvent(SCRIPT_TRIGGER_TYPE trigger, BASE_OBJECT *psObj)
{
// HACK: TRIGGER_VIDEO_QUIT is called before scripts for initial campaign video
Expand Down Expand Up @@ -1055,6 +1075,39 @@ bool triggerEvent(SCRIPT_TRIGGER_TYPE trigger, BASE_OBJECT *psObj)
case TRIGGER_GAME_SAVED:
callFunction(engine, "eventGameSaved", QScriptValueList());
break;
case TRIGGER_DESIGN_BODY:
callFunction(engine, "eventDesignBody", QScriptValueList());
break;
case TRIGGER_DESIGN_PROPULSION:
callFunction(engine, "eventDesignPropulsion", QScriptValueList());
break;
case TRIGGER_DESIGN_WEAPON:
callFunction(engine, "eventDesignWeapon", QScriptValueList());
break;
case TRIGGER_DESIGN_COMMAND:
callFunction(engine, "eventDesignCommand", QScriptValueList());
break;
case TRIGGER_DESIGN_SYSTEM:
callFunction(engine, "eventDesignSystem", QScriptValueList());
break;
case TRIGGER_DESIGN_QUIT:
callFunction(engine, "eventDesignQuit", QScriptValueList());
break;
case TRIGGER_MENU_BUILD_SELECTED:
callFunction(engine, "eventMenuBuildSelected", args);
break;
case TRIGGER_MENU_BUILD_UP:
args += QScriptValue(true);
callFunction(engine, "eventMenuBuild", args);
break;
case TRIGGER_MENU_RESEARCH_UP:
args += QScriptValue(true);
callFunction(engine, "eventMenuResearch", args);
break;
case TRIGGER_MENU_MANUFACTURE_UP:
args += QScriptValue(true);
callFunction(engine, "eventMenuManufacture", args);
break;
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/qtscript.h
Expand Up @@ -46,6 +46,16 @@ enum SCRIPT_TRIGGER_TYPE
TRIGGER_GAME_LOADED,
TRIGGER_GAME_SAVING,
TRIGGER_GAME_SAVED,
TRIGGER_DESIGN_BODY,
TRIGGER_DESIGN_WEAPON,
TRIGGER_DESIGN_COMMAND,
TRIGGER_DESIGN_SYSTEM,
TRIGGER_DESIGN_PROPULSION,
TRIGGER_DESIGN_QUIT,
TRIGGER_MENU_BUILD_UP,
TRIGGER_MENU_BUILD_SELECTED,
TRIGGER_MENU_MANUFACTURE_UP,
TRIGGER_MENU_RESEARCH_UP,
TRIGGER_OBJECT_RECYCLED
};

Expand Down

0 comments on commit 629d437

Please sign in to comment.