找回密码
 点一下
查看: 1661|回复: 4

bank储存布尔值到本地文件,读取却不成功

[复制链接]
发表于 2010-12-29 01:18:28 | 显示全部楼层 |阅读模式
//直接贴这个文件的代码吧 红色是关键


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();
}
 楼主| 发表于 2010-12-29 01:23:42 | 显示全部楼层
打开bank文件夹可以看到,值确实储存了,而且储存的正确。
但每次一开始读取到的总是false。
(如果操作一下设置值为true,再读取就正常为true)
回复

使用道具 举报

 楼主| 发表于 2010-12-29 06:14:40 | 显示全部楼层
问题找到了,似乎是那个getlocalplayer没有正确返回值
奇怪阿。。平常都正常的
回复

使用道具 举报

 楼主| 发表于 2010-12-29 07:32:25 | 显示全部楼层
无论怎样都不行。难道是欺负我不是从地图中调用bankload?
怒了!直接用GetPrivateProfileInt读自定义文件了
回复

使用道具 举报

发表于 2010-12-29 08:36:45 | 显示全部楼层
getlocalplayer?你这不是自己改的函数么?

你都改了程序了,出现异常很正常吧。


正常的bank是没问题的。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-12-23 18:13 , Processed in 0.053314 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表