Commit b48004a2 authored by nanahira's avatar nanahira

Merge branch 'regex_fh_'

parents 2ddb1804 05ee5b66
......@@ -318,7 +318,13 @@ int DataManager::CardReader(int code, void* pData) {
return 0;
}
byte* DataManager::ScriptReaderEx(const char* script_name, int* slen) {
byte* buffer = ScriptReaderExDirectry("./specials", script_name, slen, 8);
byte* buffer;
if(!mainGame->gameConf.prefer_expansion_script) {
buffer = ScriptReaderExDirectry(".", script_name, slen);
if(buffer)
return buffer;
}
buffer = ScriptReaderExDirectry("./specials", script_name, slen, 8);
if(buffer)
return buffer;
buffer = ScriptReaderExDirectry("./expansions", script_name, slen);
......
......@@ -1894,6 +1894,11 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true;
break;
}
case CHECKBOX_PREFER_EXPANSION: {
mainGame->gameConf.prefer_expansion_script = mainGame->chkPreferExpansionScript->isChecked() ? 1 : 0;
return true;
break;
}
}
break;
}
......@@ -2306,7 +2311,7 @@ void ClientField::UpdateChainButtons() {
}
}
void ClientField::ShowCancelOrFinishButton(int buttonOp) {
if (!mainGame->chkHideHintButton->isChecked() && !mainGame->dInfo.isReplay) {
if (!mainGame->gameConf.hide_hint_button && !mainGame->dInfo.isReplay) {
switch (buttonOp) {
case 1:
mainGame->btnCancelOrFinish->setText(dataManager.GetSysString(1295));
......
......@@ -329,12 +329,6 @@ bool Game::Initialize() {
chkIgnore2 = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1291));
chkIgnore2->setChecked(gameConf.chkIgnore2 != 0);
posY += 30;
chkHideSetname = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1354));
chkHideSetname->setChecked(gameConf.chkHideSetname != 0);
posY += 30;
chkHideHintButton = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1355));
chkHideHintButton->setChecked(gameConf.chkHideHintButton != 0);
posY += 30;
chkIgnoreDeckChanges = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1357));
chkIgnoreDeckChanges->setChecked(gameConf.chkIgnoreDeckChanges != 0);
posY += 30;
......@@ -344,9 +338,12 @@ bool Game::Initialize() {
chkMultiKeywords = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, CHECKBOX_MULTI_KEYWORDS, dataManager.GetSysString(1378));
chkMultiKeywords->setChecked(gameConf.search_multiple_keywords > 0);
posY += 30;
chkRegex = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, CHECKBOX_REGEX, dataManager.GetSysString(1379));
chkRegex = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, CHECKBOX_REGEX, dataManager.GetSysString(1386));
chkRegex->setChecked(gameConf.search_regex > 0);
posY += 30;
chkPreferExpansionScript = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, CHECKBOX_PREFER_EXPANSION, dataManager.GetSysString(1379));
chkPreferExpansionScript->setChecked(gameConf.prefer_expansion_script != 0);
posY += 30;
env->addStaticText(dataManager.GetSysString(1282), rect<s32>(posX + 23, posY + 3, posX + 120, posY + 28), false, false, tabSystem);
btnWinResizeS = env->addButton(rect<s32>(posX + 115, posY, posX + 145, posY + 25), tabSystem, BUTTON_WINDOW_RESIZE_S, dataManager.GetSysString(1283));
btnWinResizeM = env->addButton(rect<s32>(posX + 150, posY, posX + 180, posY + 25), tabSystem, BUTTON_WINDOW_RESIZE_M, dataManager.GetSysString(1284));
......@@ -706,7 +703,7 @@ bool Game::Initialize() {
btnLoadSinglePlay = env->addButton(rect<s32>(459, 301, 569, 326), tabSingle, BUTTON_LOAD_SINGLEPLAY, dataManager.GetSysString(1211));
btnSinglePlayCancel = env->addButton(rect<s32>(459, 331, 569, 356), tabSingle, BUTTON_CANCEL_SINGLEPLAY, dataManager.GetSysString(1210));
env->addStaticText(dataManager.GetSysString(1352), rect<s32>(360, 10, 550, 30), false, true, tabSingle);
stSinglePlayInfo = env->addStaticText(L"", rect<s32>(360, 40, 550, 280), false, true, tabSingle);
stSinglePlayInfo = env->addStaticText(L"", rect<s32>(360, 40, 560, 280), false, true, tabSingle);
//replay save
wReplaySave = env->addWindow(rect<s32>(510, 200, 820, 320), false, dataManager.GetSysString(1340));
wReplaySave->getCloseButton()->setVisible(false);
......@@ -1031,6 +1028,7 @@ void Game::RefreshReplay() {
}
void Game::RefreshSingleplay() {
lstSinglePlayList->clear();
stSinglePlayInfo->setText(L"");
FileSystem::TraversalDir(L"./single", [this](const wchar_t* name, bool isdir) {
if(!isdir && wcsrchr(name, '.') && !mywcsncasecmp(wcsrchr(name, '.'), L".lua", 4))
lstSinglePlayList->addItem(name);
......@@ -1122,8 +1120,8 @@ void Game::LoadConfig() {
gameConf.chkWaitChain = 0;
gameConf.chkIgnore1 = 0;
gameConf.chkIgnore2 = 0;
gameConf.chkHideSetname = 0;
gameConf.chkHideHintButton = 0;
gameConf.hide_setname = 0;
gameConf.hide_hint_button = 0;
gameConf.control_mode = 0;
gameConf.draw_field_spell = 1;
gameConf.separate_clear_button = 1;
......@@ -1135,6 +1133,7 @@ void Game::LoadConfig() {
gameConf.enable_bot_mode = 1;
gameConf.quick_animation = 0;
gameConf.auto_save_replay = 0;
gameConf.prefer_expansion_script = 0;
gameConf.enable_sound = true;
gameConf.sound_volume = 0.5;
gameConf.enable_music = true;
......@@ -1194,9 +1193,9 @@ void Game::LoadConfig() {
} else if(!strcmp(strbuf, "mute_spectators")) {
gameConf.chkIgnore2 = atoi(valbuf);
} else if(!strcmp(strbuf, "hide_setname")) {
gameConf.chkHideSetname = atoi(valbuf);
gameConf.hide_setname = atoi(valbuf);
} else if(!strcmp(strbuf, "hide_hint_button")) {
gameConf.chkHideHintButton = atoi(valbuf);
gameConf.hide_hint_button = atoi(valbuf);
} else if(!strcmp(strbuf, "control_mode")) {
gameConf.control_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "draw_field_spell")) {
......@@ -1219,6 +1218,8 @@ void Game::LoadConfig() {
gameConf.quick_animation = atoi(valbuf);
} else if(!strcmp(strbuf, "auto_save_replay")) {
gameConf.auto_save_replay = atoi(valbuf);
} else if(!strcmp(strbuf, "prefer_expansion_script")) {
gameConf.prefer_expansion_script = atoi(valbuf);
} else if(!strcmp(strbuf, "window_maximized")) {
gameConf.window_maximized = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "window_width")) {
......@@ -1312,9 +1313,9 @@ void Game::LoadConfig() {
} else if(!strcmp(strbuf, "mute_spectators")) {
gameConf.chkIgnore2 = atoi(valbuf);
} else if(!strcmp(strbuf, "hide_setname")) {
gameConf.chkHideSetname = atoi(valbuf);
gameConf.hide_setname = atoi(valbuf);
} else if(!strcmp(strbuf, "hide_hint_button")) {
gameConf.chkHideHintButton = atoi(valbuf);
gameConf.hide_hint_button = atoi(valbuf);
} else if(!strcmp(strbuf, "control_mode")) {
gameConf.control_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "draw_field_spell")) {
......@@ -1337,6 +1338,8 @@ void Game::LoadConfig() {
gameConf.quick_animation = atoi(valbuf);
} else if(!strcmp(strbuf, "auto_save_replay")) {
gameConf.auto_save_replay = atoi(valbuf);
} else if(!strcmp(strbuf, "prefer_expansion_script")) {
gameConf.prefer_expansion_script = atoi(valbuf);
} else if(!strcmp(strbuf, "window_maximized")) {
gameConf.window_maximized = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "window_width")) {
......@@ -1447,8 +1450,8 @@ void Game::SaveConfig() {
fprintf(fp, "waitchain = %d\n", (chkWaitChain->isChecked() ? 1 : 0));
fprintf(fp, "mute_opponent = %d\n", (chkIgnore1->isChecked() ? 1 : 0));
fprintf(fp, "mute_spectators = %d\n", (chkIgnore2->isChecked() ? 1 : 0));
fprintf(fp, "hide_setname = %d\n", (chkHideSetname->isChecked() ? 1 : 0));
fprintf(fp, "hide_hint_button = %d\n", (chkHideHintButton->isChecked() ? 1 : 0));
fprintf(fp, "hide_setname = %d\n", gameConf.hide_setname);
fprintf(fp, "hide_hint_button = %d\n", gameConf.hide_hint_button);
fprintf(fp, "#control_mode = 0: Key A/S/D/R Chain Buttons. control_mode = 1: MouseLeft/MouseRight/NULL/F9 Without Chain Buttons\n");
fprintf(fp, "control_mode = %d\n", gameConf.control_mode);
fprintf(fp, "draw_field_spell = %d\n", gameConf.draw_field_spell);
......@@ -1463,6 +1466,7 @@ void Game::SaveConfig() {
fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode);
fprintf(fp, "quick_animation = %d\n", gameConf.quick_animation);
fprintf(fp, "auto_save_replay = %d\n", (chkAutoSaveReplay->isChecked() ? 1 : 0));
fprintf(fp, "prefer_expansion_script = %d\n", gameConf.prefer_expansion_script);
fprintf(fp, "window_maximized = %d\n", (gameConf.window_maximized ? 1 : 0));
fprintf(fp, "window_width = %d\n", gameConf.window_width);
fprintf(fp, "window_height = %d\n", gameConf.window_height);
......@@ -1499,7 +1503,7 @@ void Game::ShowCardInfo(int code, bool resize) {
else myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(code), code);
stName->setText(formatBuffer);
int offset = 0;
if(!chkHideSetname->isChecked()) {
if(!gameConf.hide_setname) {
unsigned long long sc = cd.setcode;
if(cd.alias) {
auto aptr = dataManager._datas.find(cd.alias);
......
......@@ -35,8 +35,8 @@ struct Config {
int chkWaitChain;
int chkIgnore1;
int chkIgnore2;
int chkHideSetname;
int chkHideHintButton;
int hide_setname;
int hide_hint_button;
int control_mode;
int draw_field_spell;
int separate_clear_button;
......@@ -52,6 +52,7 @@ struct Config {
int window_height;
bool resize_popup_menu;
int auto_save_replay;
int prefer_expansion_script;
bool enable_sound;
bool enable_music;
double sound_volume;
......@@ -304,11 +305,10 @@ public:
irr::gui::IGUIWindow* tabSystem;
irr::gui::IGUIElement* elmTabSystemLast;
irr::gui::IGUIScrollBar* scrTabSystem;
irr::gui::IGUICheckBox* chkHideSetname;
irr::gui::IGUICheckBox* chkHideHintButton;
irr::gui::IGUICheckBox* chkIgnoreDeckChanges;
irr::gui::IGUICheckBox* chkAutoSearch;
irr::gui::IGUICheckBox* chkMultiKeywords;
irr::gui::IGUICheckBox* chkPreferExpansionScript;
irr::gui::IGUICheckBox* chkRegex;
irr::gui::IGUICheckBox* chkEnableSound;
irr::gui::IGUICheckBox* chkEnableMusic;
......@@ -722,7 +722,8 @@ extern Game* mainGame;
#define SCROLL_TAB_SYSTEM 351
#define CHECKBOX_AUTO_SEARCH 360
#define CHECKBOX_MULTI_KEYWORDS 372
#define CHECKBOX_REGEX 373
#define CHECKBOX_PREFER_EXPANSION 373
#define CHECKBOX_REGEX 374
#define CHECKBOX_ENABLE_SOUND 361
#define CHECKBOX_ENABLE_MUSIC 362
#define SCROLL_VOLUME 363
......
......@@ -497,6 +497,55 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->SetStaticText(mainGame->stReplayInfo, 180, mainGame->guiFont, repinfo.c_str());
break;
}
case LISTBOX_SINGLEPLAY_LIST: {
int sel = mainGame->lstSinglePlayList->getSelected();
if(sel == -1)
break;
const wchar_t* name = mainGame->lstSinglePlayList->getListItem(sel);
wchar_t fname[256];
myswprintf(fname, L"./single/%ls", name);
FILE *fp;
#ifdef _WIN32
fp = _wfopen(fname, L"rb");
#else
char filename[256];
BufferIO::EncodeUTF8(fname, filename);
fp = fopen(filename, "rb");
#endif
if(!fp) {
mainGame->stSinglePlayInfo->setText(L"");
break;
}
char linebuf[1024];
wchar_t wlinebuf[1024];
std::wstring message = L"";
bool in_message = false;
while(fgets(linebuf, 1024, fp)) {
if(!strncmp(linebuf, "--[[message", 11)) {
size_t len = strlen(linebuf);
char* msgend = strrchr(linebuf, ']');
if(len <= 13) {
in_message = true;
continue;
} else if(len > 15 && msgend) {
*(msgend - 1) = '\0';
BufferIO::DecodeUTF8(linebuf + 12, wlinebuf);
message.append(wlinebuf);
break;
}
}
if(!strncmp(linebuf, "]]", 2)) {
in_message = false;
break;
}
if(in_message) {
BufferIO::DecodeUTF8(linebuf, wlinebuf);
message.append(wlinebuf);
}
}
mainGame->SetStaticText(mainGame->stSinglePlayInfo, 200, mainGame->guiFont, message.c_str());
break;
}
case LISTBOX_BOT_LIST: {
int sel = mainGame->lstBotList->getSelected();
if(sel == -1)
......
......@@ -390,8 +390,6 @@
!system 1351 投降
!system 1352 主要信息:
!system 1353 播放起始于回合:
!system 1354 不显示卡片系列
!system 1355 不显示提示按钮
!system 1356 是否要放弃对卡组的修改?
!system 1357 不提示保留对卡组的修改
!system 1358 键入关键字后自动进行搜索
......@@ -414,13 +412,14 @@
!system 1376 重命名卡组
!system 1377 卡组文件:
!system 1378 使用多个关键词搜索卡片
!system 1379 使用正则表达式搜索卡片
!system 1379 启用扩展卡包调试模式
!system 1380 人机模式
!system 1381 残局模式
!system 1382 人机信息:
!system 1383 使用旧规则(大师规则3)
!system 1384 电脑锁定出剪刀
!system 1385 列表为空,可能未安装合适的人机
!system 1386 使用正则表达式搜索卡片
!system 1390 等待行动中...
!system 1391 等待行动中....
!system 1392 等待行动中.....
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment