Skip to content

Commit

Permalink
qtscript: Add two new functions: showInterface() and hideInterface().…
Browse files Browse the repository at this point in the history
… They currently

only serve to assist modifications of the reticule, but will eventually control
hide/show of the larger user interface widgets. Also fix alpha values on two reticule
images.
  • Loading branch information
perim committed Aug 2, 2013
1 parent cd54d38 commit c0abe4e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 7 deletions.
Binary file modified data/base/images/intfac/image_attack_down.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/base/images/intfac/image_attack_up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/base/script/rules.js
Expand Up @@ -16,6 +16,7 @@ function eventGameInit()
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");
showInterface();
}

function eventStartLevel()
Expand Down
1 change: 1 addition & 0 deletions data/mp/multiplay/skirmish/rules.js
Expand Up @@ -20,6 +20,7 @@ function eventGameInit()
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");
showInterface();

if (tilesetType != "ARIZONA")
{
Expand Down
2 changes: 1 addition & 1 deletion src/hci.cpp
Expand Up @@ -797,7 +797,7 @@ static void intDoScreenRefresh(void)


//hides the power bar from the display
static void intHidePowerBar(void)
void intHidePowerBar()
{
//only hides the power bar if the player has requested no power bar
if (!powerBarUp)
Expand Down
7 changes: 3 additions & 4 deletions src/hci.h
Expand Up @@ -333,10 +333,9 @@ extern void flashReticuleButton(UDWORD buttonID);
extern void stopReticuleButtonFlash(UDWORD buttonID);

//toggles the Power Bar display on and off
extern void togglePowerBar(void);

//displays the Power Bar
extern void intShowPowerBar(void);
void togglePowerBar();
void intShowPowerBar();
void intHidePowerBar();

//hides the power bar from the display - regardless of what player requested!
extern void forceHidePowerBar(void);
Expand Down
1 change: 0 additions & 1 deletion src/init.cpp
Expand Up @@ -1221,7 +1221,6 @@ bool stageThreeInitialise(void)
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_GAMEINIT);
triggerEvent(TRIGGER_GAME_INIT);
}
intAddReticule();
intAddPower();

return true;
Expand Down
21 changes: 20 additions & 1 deletion src/qtscriptfuncs.cpp
Expand Up @@ -2718,7 +2718,8 @@ static QScriptValue js_enableTemplate(QScriptContext *context, QScriptEngine *en
//-- \subsection{setReticuleButton(id, filename, filenameHigh, tooltip, callback)} Add reticule button. id is which
//-- button to change, where zero is zero is the middle button, then going clockwise from the uppermost
//-- button. filename is button graphics and filenameHigh is for highlighting. The tooltip is the text you see when you
//-- mouse over the button. Finally, the callback is which scripting function to call
//-- mouse over the button. Finally, the callback is which scripting function to call. Hide and show the user interface
//-- for such changes to take effect.
static QScriptValue js_setReticuleButton(QScriptContext *context, QScriptEngine *engine)
{
int button = context->argument(0).toInt32();
Expand All @@ -2730,6 +2731,22 @@ static QScriptValue js_setReticuleButton(QScriptContext *context, QScriptEngine
return QScriptValue();
}

//-- \subsection{showInterface()} Show user interface.
static QScriptValue js_showInterface(QScriptContext *context, QScriptEngine *engine)
{
intAddReticule();
intShowPowerBar();
return QScriptValue();
}

//-- \subsection{hideInterface(button type)} Hide user interface.
static QScriptValue js_hideInterface(QScriptContext *context, QScriptEngine *engine)
{
intRemoveReticule();
intHidePowerBar();
return QScriptValue();
}

//-- \subsection{removeReticuleButton(button type)} Remove reticule button. DO NOT USE FOR ANYTHING.
static QScriptValue js_removeReticuleButton(QScriptContext *context, QScriptEngine *engine)
{
Expand Down Expand Up @@ -4487,6 +4504,8 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
engine->globalObject().setProperty("enableTemplate", engine->newFunction(js_enableTemplate));
engine->globalObject().setProperty("setMiniMap", engine->newFunction(js_setMiniMap));
engine->globalObject().setProperty("setReticuleButton", engine->newFunction(js_setReticuleButton));
engine->globalObject().setProperty("showInterface", engine->newFunction(js_showInterface));
engine->globalObject().setProperty("hideInterface", engine->newFunction(js_hideInterface));
engine->globalObject().setProperty("addReticuleButton", engine->newFunction(js_removeReticuleButton)); // deprecated!!
engine->globalObject().setProperty("removeReticuleButton", engine->newFunction(js_removeReticuleButton));
engine->globalObject().setProperty("enableStructure", engine->newFunction(js_enableStructure));
Expand Down

0 comments on commit c0abe4e

Please sign in to comment.