Commit 9523c6e5 authored by nanahira's avatar nanahira

Merge branch 'fh' into deck_code_fh

parents 37ad35fb fe7b8211
...@@ -594,18 +594,23 @@ void ClientField::ShowSelectOption(int select_hint) { ...@@ -594,18 +594,23 @@ void ClientField::ShowSelectOption(int select_hint) {
selected_option = 0; selected_option = 0;
wchar_t textBuffer[256]; wchar_t textBuffer[256];
int count = select_options.size(); int count = select_options.size();
bool quickmode = (count <= 5); bool quickmode = true;
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
for(int i = 0; (i < count) && quickmode; i++) { for(auto option : select_options) {
const wchar_t* option = dataManager.GetDesc(select_options[i]); if(mainGame->guiFont->getDimension(dataManager.GetDesc(option)).Width > 310) {
irr::core::dimension2d<unsigned int> dtxt = mainGame->guiFont->getDimension(option);
if(dtxt.Width > 310) {
quickmode = false; quickmode = false;
break; break;
} }
}
for(int i = 0; (i < count) && (i < 5) && quickmode; i++) {
const wchar_t* option = dataManager.GetDesc(select_options[i]);
mainGame->btnOption[i]->setText(option); mainGame->btnOption[i]->setText(option);
} }
if(quickmode) { if(quickmode) {
bool scrollbar = count > 5;
mainGame->scrOption->setVisible(scrollbar);
mainGame->scrOption->setPos(0);
mainGame->scrOption->setMax(scrollbar ? (count - 5) : 1);
mainGame->stOptions->setVisible(false); mainGame->stOptions->setVisible(false);
mainGame->btnOptionp->setVisible(false); mainGame->btnOptionp->setVisible(false);
mainGame->btnOptionn->setVisible(false); mainGame->btnOptionn->setVisible(false);
...@@ -613,9 +618,10 @@ void ClientField::ShowSelectOption(int select_hint) { ...@@ -613,9 +618,10 @@ void ClientField::ShowSelectOption(int select_hint) {
for(int i = 0; i < 5; i++) for(int i = 0; i < 5; i++)
mainGame->btnOption[i]->setVisible(i < count); mainGame->btnOption[i]->setVisible(i < count);
recti pos = mainGame->wOptions->getRelativePosition(); recti pos = mainGame->wOptions->getRelativePosition();
int newheight = 30 + 40 * count; int newheight = 30 + 40 * (scrollbar ? 5 : count);
int oldheight = pos.LowerRightCorner.Y - pos.UpperLeftCorner.Y; int oldheight = pos.LowerRightCorner.Y - pos.UpperLeftCorner.Y;
pos.UpperLeftCorner.Y = pos.UpperLeftCorner.Y + (oldheight - newheight) / 2; pos.UpperLeftCorner.Y = pos.UpperLeftCorner.Y + (oldheight - newheight) / 2;
pos.LowerRightCorner.X = pos.UpperLeftCorner.X + (scrollbar ? 375 : 350);
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + newheight; pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + newheight;
mainGame->wOptions->setRelativePosition(pos); mainGame->wOptions->setRelativePosition(pos);
} else { } else {
......
...@@ -375,6 +375,12 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -375,6 +375,12 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break; break;
} }
case irr::gui::EGET_SCROLL_BAR_CHANGED: { case irr::gui::EGET_SCROLL_BAR_CHANGED: {
switch(id) {
case SCROLL_FILTER: {
GetHoveredCard();
break;
}
}
break; break;
} }
case irr::gui::EGET_EDITBOX_ENTER: { case irr::gui::EGET_EDITBOX_ENTER: {
......
...@@ -291,33 +291,14 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -291,33 +291,14 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->guiFont, dataManager.GetDesc(select_options[selected_option])); mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->guiFont, dataManager.GetDesc(select_options[selected_option]));
break; break;
} }
case BUTTON_OPTION_0: { case BUTTON_OPTION_0:
soundManager.PlaySoundEffect(SOUND_BUTTON); case BUTTON_OPTION_1:
selected_option = 0; case BUTTON_OPTION_2:
SetResponseSelectedOption(); case BUTTON_OPTION_3:
break;
}
case BUTTON_OPTION_1: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option = 1;
SetResponseSelectedOption();
break;
}
case BUTTON_OPTION_2: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option = 2;
SetResponseSelectedOption();
break;
}
case BUTTON_OPTION_3: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option = 3;
SetResponseSelectedOption();
break;
}
case BUTTON_OPTION_4: { case BUTTON_OPTION_4: {
soundManager.PlaySoundEffect(SOUND_BUTTON); soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option = 4; int step = mainGame->scrOption->isVisible() ? mainGame->scrOption->getPos() : 0;
selected_option = id - BUTTON_OPTION_0 + step;
SetResponseSelectedOption(); SetResponseSelectedOption();
break; break;
} }
...@@ -846,6 +827,14 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -846,6 +827,14 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
case irr::gui::EGET_SCROLL_BAR_CHANGED: { case irr::gui::EGET_SCROLL_BAR_CHANGED: {
switch(id) { switch(id) {
case SCROLL_OPTION_SELECT: {
int step = mainGame->scrOption->isVisible() ? mainGame->scrOption->getPos() : 0;
for(int i = 0; i < 5; i++) {
const wchar_t* option = dataManager.GetDesc(select_options[i + step]);
mainGame->btnOption[i]->setText(option);
}
break;
}
case SCROLL_CARD_SELECT: { case SCROLL_CARD_SELECT: {
int pos = mainGame->scrCardList->getPos() / 10; int pos = mainGame->scrCardList->getPos() / 10;
for(int i = 0; i < 5; ++i) { for(int i = 0; i < 5; ++i) {
......
...@@ -397,6 +397,10 @@ bool Game::Initialize() { ...@@ -397,6 +397,10 @@ bool Game::Initialize() {
for(int i = 0; i < 5; ++i) { for(int i = 0; i < 5; ++i) {
btnOption[i] = env->addButton(rect<s32>(10, 30 + 40 * i, 340, 60 + 40 * i), wOptions, BUTTON_OPTION_0 + i, L""); btnOption[i] = env->addButton(rect<s32>(10, 30 + 40 * i, 340, 60 + 40 * i), wOptions, BUTTON_OPTION_0 + i, L"");
} }
scrOption = env->addScrollBar(false, rect<s32>(350, 30, 365, 220), wOptions, SCROLL_OPTION_SELECT);
scrOption->setLargeStep(1);
scrOption->setSmallStep(1);
scrOption->setMin(0);
//pos select //pos select
wPosSelect = env->addWindow(rect<s32>(340, 200, 935, 410), false, dataManager.GetSysString(561)); wPosSelect = env->addWindow(rect<s32>(340, 200, 935, 410), false, dataManager.GetSysString(561));
wPosSelect->getCloseButton()->setVisible(false); wPosSelect->getCloseButton()->setVisible(false);
......
...@@ -388,6 +388,7 @@ public: ...@@ -388,6 +388,7 @@ public:
irr::gui::IGUIButton* btnOptionn; irr::gui::IGUIButton* btnOptionn;
irr::gui::IGUIButton* btnOptionOK; irr::gui::IGUIButton* btnOptionOK;
irr::gui::IGUIButton* btnOption[5]; irr::gui::IGUIButton* btnOption[5];
irr::gui::IGUIScrollBar* scrOption;
//pos selection //pos selection
irr::gui::IGUIWindow* wPosSelect; irr::gui::IGUIWindow* wPosSelect;
irr::gui::CGUIImageButton* btnPSAU; irr::gui::CGUIImageButton* btnPSAU;
...@@ -602,6 +603,7 @@ extern Game* mainGame; ...@@ -602,6 +603,7 @@ extern Game* mainGame;
#define BUTTON_OPTION_2 225 #define BUTTON_OPTION_2 225
#define BUTTON_OPTION_3 226 #define BUTTON_OPTION_3 226
#define BUTTON_OPTION_4 227 #define BUTTON_OPTION_4 227
#define SCROLL_OPTION_SELECT 228
#define BUTTON_CARD_0 230 #define BUTTON_CARD_0 230
#define BUTTON_CARD_1 231 #define BUTTON_CARD_1 231
#define BUTTON_CARD_2 232 #define BUTTON_CARD_2 232
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#ifndef _WIN32 #ifndef _WIN32
#include <dirent.h> #include <dirent.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <vector>
#include <algorithm>
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
...@@ -109,21 +111,41 @@ public: ...@@ -109,21 +111,41 @@ public:
return MakeDir(dir); return MakeDir(dir);
} }
struct file_unit {
std::string filename;
bool is_dir;
};
static void TraversalDir(const char* path, const std::function<void(const char*, bool)>& cb) { static void TraversalDir(const char* path, const std::function<void(const char*, bool)>& cb) {
DIR* dir = nullptr; DIR* dir = nullptr;
struct dirent* dirp = nullptr; struct dirent* dirp = nullptr;
if((dir = opendir(path)) == nullptr) if((dir = opendir(path)) == nullptr)
return; return;
struct stat fileStat; struct stat fileStat;
std::vector<file_unit> file_list;
while((dirp = readdir(dir)) != nullptr) { while((dirp = readdir(dir)) != nullptr) {
file_unit funit;
char fname[1024]; char fname[1024];
strcpy(fname, path); strcpy(fname, path);
strcat(fname, "/"); strcat(fname, "/");
strcat(fname, dirp->d_name); strcat(fname, dirp->d_name);
stat(fname, &fileStat); stat(fname, &fileStat);
cb(dirp->d_name, S_ISDIR(fileStat.st_mode)); funit.filename = std::string(dirp->d_name);
funit.is_dir = S_ISDIR(fileStat.st_mode);
file_list.push_back(funit);
} }
closedir(dir); closedir(dir);
std::sort(file_list.begin(), file_list.end(), TraversalDirSort);
for (file_unit funit : file_list)
cb(funit.filename.c_str(), funit.is_dir);
}
static bool TraversalDirSort(file_unit file1, file_unit file2) {
if(file1.is_dir != file2.is_dir) {
return file2.is_dir;
} else {
return file1.filename < file2.filename;
}
} }
static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) { static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) {
......
...@@ -731,7 +731,7 @@ ...@@ -731,7 +731,7 @@
!setname 0x73 超量 エクシーズ !setname 0x73 超量 エクシーズ
!setname 0x1073 混沌超量 CX(カオスエクシーズ) !setname 0x1073 混沌超量 CX(カオスエクシーズ)
!setname 0x2073 超量龙 エクシーズ・ドラゴン !setname 0x2073 超量龙 エクシーズ・ドラゴン
!setname 0x74 水精鱗 !setname 0x74 水精鳞 水精
!setname 0x75 深渊 アビス !setname 0x75 深渊 アビス
!setname 0x76 纹章兽 紋章獣 !setname 0x76 纹章兽 紋章獣
!setname 0x77 海皇 !setname 0x77 海皇
......
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