|
//直接贴这个文件的代码吧 红色是关键
include "TriggerLibs/dreamgalaxy"
include "TriggerLibs/NativeLib"
include "TriggerLibs/MassAction"
//--------------------------------------------------------------------------------------------------
// Global Variables
//--------------------------------------------------------------------------------------------------
int gv_theDialog;
int gv_checkbox_improvedProduction;
bank dreamgalaxybank;
void Menu_InitGlobals () {
gv_theDialog = c_invalidDialogId;
gv_checkbox_improvedProduction = c_invalidDialogControlId;
}
//--------------------------------------------------------------------------------------------------
// Trigger Variables
//--------------------------------------------------------------------------------------------------
trigger gt_InitBoardItems;
trigger gt_InitBoard;
trigger gt_ShowBoard;
trigger gt_UpdateSettings;
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Trigger: InitBoardItems
//--------------------------------------------------------------------------------------------------
bool gt_InitBoardItems_Func (bool testConds, bool runActions) {
BankLoad("DreamGalaxyBank", GetLocalPlayer());
dreamgalaxybank = BankLastCreated();
// Actions
if (!runActions) {
return true;
}
libNtve_gf_CreateDialogItemLabel(gv_theDialog, 550, 50, c_anchorTop, 88, 50, StringToText("<s val=\"BoardTitle\">DreamGalaxy Settings</s>"), Color(100,100,100), false, 2.0);
libNtve_gf_CreateDialogItemLabel(gv_theDialog, 300, 50, c_anchorTopLeft, 100, 112, StringToText("<s val=\"StandardLabel\">Enable Improved Production</s>"), Color(100,100,100), false, 2.0);
MassAction_Enabled = BankValueGetAsFlag(dreamgalaxybank, "features", "improvedproduction"); //这里变量是其它galaxy文件中的bool
libNtve_gf_CreateDialogItemCheckBox(gv_theDialog, 200, 50, c_anchorTopLeft, 300, 100, StringToText(""), MassAction_Enabled);
gv_checkbox_improvedProduction = DialogControlLastCreated();
return true;
}
//--------------------------------------------------------------------------------------------------
void gt_InitBoardItems_Init () {
gt_InitBoardItems = TriggerCreate("gt_InitBoardItems_Func");
}
//--------------------------------------------------------------------------------------------------
// Trigger: InitBoard
//--------------------------------------------------------------------------------------------------
bool gt_InitBoard_Func (bool testConds, bool runActions) {
// Actions
if (!runActions) {
return true;
}
DialogCreate(500, 400, c_anchorCenter, 0, 0, true);
gv_theDialog = DialogLastCreated();
TriggerExecute(gt_InitBoardItems, false, false);
return true;
}
//--------------------------------------------------------------------------------------------------
void gt_InitBoard_Init () {
gt_InitBoard = TriggerCreate("gt_InitBoard_Func");
TriggerAddEventMapInit(gt_InitBoard);
}
//--------------------------------------------------------------------------------------------------
// Trigger: ShowBoard
//--------------------------------------------------------------------------------------------------
bool gt_ShowBoard_Func (bool testConds, bool runActions) {
// Actions
if (!runActions) {
return true;
}
if ((DialogIsVisible(gv_theDialog, 0) == true)) {
DialogSetVisible(gv_theDialog, PlayerGroupAll(), false);
}
else {
DialogSetVisible(gv_theDialog, PlayerGroupAll(), true);
}
return true;
}
//--------------------------------------------------------------------------------------------------
void gt_ShowBoard_Init () {
gt_ShowBoard = TriggerCreate("gt_ShowBoard_Func");
TriggerAddEventKeyPressed(gt_ShowBoard, c_playerAny, c_keyF7, true, c_keyModifierStateExclude, c_keyModifierStateExclude, c_keyModifierStateExclude);
}
//--------------------------------------------------------------------------------------------------
// Trigger: UpdateSettings
//--------------------------------------------------------------------------------------------------
bool gt_UpdateSettings_Func (bool testConds, bool runActions) {
// Variable Declarations
int lv_item;
// Variable Initialization
lv_item = EventDialogControl();
// Actions
if (!runActions) {
return true;
}
if ((lv_item == gv_checkbox_improvedProduction)) {
if (gv_checkbox_improvedProduction != c_invalidDialogControlId){
if ((libNtve_gf_DialogItemIsChecked(EventDialogControl(), EventPlayer()) == true)) {
//UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText("Enabled"));
BankValueSetFromFlag(dreamgalaxybank, "features", "improvedproduction", true);
BankSave(dreamgalaxybank);
MassAction_Enabled = true;
}
else {
//UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText("Disabled"));
BankValueSetFromFlag(dreamgalaxybank, "features", "improvedproduction", false);
BankSave(dreamgalaxybank);
MassAction_Enabled = false;
//以上两处都正常运行
}
}
}
else {
}
return true;
}
//--------------------------------------------------------------------------------------------------
void gt_UpdateSettings_Init () {
gt_UpdateSettings = TriggerCreate("gt_UpdateSettings_Func");
TriggerAddEventDialogControl(gt_UpdateSettings, c_playerAny, c_invalidDialogControlId, c_triggerControlEventTypeChecked);
}
void Menu_InitTriggers () {
gt_InitBoardItems_Init();
gt_InitBoard_Init();
gt_ShowBoard_Init();
gt_UpdateSettings_Init();
}
//--------------------------------------------------------------------------------------------------
// Map Initialization
//--------------------------------------------------------------------------------------------------
void Menu_TriggerInit () {
Menu_InitGlobals();
Menu_InitTriggers();
} |
|