Commit 34e9abd9 authored by fallenstardust's avatar fallenstardust

update gframe

parent 8a717caf
......@@ -27,6 +27,7 @@ ClientField::ClientField() {
hovered_card = 0;
clicked_card = 0;
highlighting_card = 0;
menu_card = 0;
hovered_controler = 0;
hovered_location = 0;
hovered_sequence = 0;
......@@ -41,6 +42,7 @@ ClientField::ClientField() {
conti_act = false;
deck_reversed = false;
conti_selecting = false;
cant_check_grave = false;
for(int p = 0; p < 2; ++p) {
mzone[p].resize(7, 0);
szone[p].resize(8, 0);
......@@ -94,6 +96,7 @@ void ClientField::Clear() {
hovered_card = 0;
clicked_card = 0;
highlighting_card = 0;
menu_card = 0;
hovered_controler = 0;
hovered_location = 0;
hovered_sequence = 0;
......@@ -105,7 +108,7 @@ void ClientField::Clear() {
pzone_act[1] = false;
conti_act = false;
deck_reversed = false;
RefreshCardCountDisplay();
cant_check_grave = false;
}
void ClientField::Initial(int player, int deckc, int extrac) {
ClientCard* pcard;
......@@ -402,6 +405,18 @@ void ClientField::ClearChainSelect() {
}
// needs to be synchronized with EGET_SCROLL_BAR_CHANGED
void ClientField::ShowSelectCard(bool buttonok, bool chain) {
if(cant_check_grave) {
bool has_card_in_grave = false;
for(size_t i = 0; i < selectable_cards.size(); ++i) {
if(selectable_cards[i]->location == LOCATION_GRAVE) {
has_card_in_grave = true;
break;
}
}
if(has_card_in_grave) {
std::random_shuffle(selectable_cards.begin(), selectable_cards.end());
}
}
int startpos;
size_t ct;
if(selectable_cards.size() <= 5) {
......@@ -428,6 +443,8 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
wchar_t formatBuffer[2048];
if(conti_selecting)
myswprintf(formatBuffer, L"%ls", DataManager::unknown_string);
else if(cant_check_grave && selectable_cards[i]->location == LOCATION_GRAVE)
myswprintf(formatBuffer, L"%ls", dataManager.FormatLocation(selectable_cards[i]->location, 0));
else if(selectable_cards[i]->location == LOCATION_OVERLAY)
myswprintf(formatBuffer, L"%ls[%d](%d)",
dataManager.FormatLocation(selectable_cards[i]->overlayTarget->location, selectable_cards[i]->overlayTarget->sequence),
......@@ -440,26 +457,27 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
if (selectable_cards[i]->is_selected)
mainGame->stCardPos[i]->setBackgroundColor(0xffa2d8f4);
else {
if(conti_selecting)
mainGame->stCardPos[i]->setBackgroundColor(0xff56649f);
else if(selectable_cards[i]->location == LOCATION_OVERLAY) {
if(selectable_cards[i]->owner != selectable_cards[i]->overlayTarget->controler)
mainGame->stCardPos[i]->setOverrideColor(0xff0000ff);
if(selectable_cards[i]->overlayTarget->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xff5a5a5a);
else mainGame->stCardPos[i]->setBackgroundColor(0xff56649f);
} else if(selectable_cards[i]->location == LOCATION_DECK || selectable_cards[i]->location == LOCATION_EXTRA || selectable_cards[i]->location == LOCATION_REMOVED) {
if(selectable_cards[i]->position & POS_FACEDOWN)
mainGame->stCardPos[i]->setOverrideColor(0xff0000ff);
if(selectable_cards[i]->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xff5a5a5a);
else
if(conti_selecting)
mainGame->stCardPos[i]->setBackgroundColor(0xff56649f);
} else {
if(selectable_cards[i]->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xff5a5a5a);
else
else if(selectable_cards[i]->location == LOCATION_OVERLAY) {
if(selectable_cards[i]->owner != selectable_cards[i]->overlayTarget->controler)
mainGame->stCardPos[i]->setOverrideColor(0xff0000ff);
if(selectable_cards[i]->overlayTarget->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xff5a5a5a);
else
mainGame->stCardPos[i]->setBackgroundColor(0xff56649f);
} else if(selectable_cards[i]->location == LOCATION_DECK || selectable_cards[i]->location == LOCATION_EXTRA || selectable_cards[i]->location == LOCATION_REMOVED) {
if(selectable_cards[i]->position & POS_FACEDOWN)
mainGame->stCardPos[i]->setOverrideColor(0xff0000ff);
if(selectable_cards[i]->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xff5a5a5a);
else
mainGame->stCardPos[i]->setBackgroundColor(0xff56649f);
} else {
if(selectable_cards[i]->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xff5a5a5a);
else
mainGame->stCardPos[i]->setBackgroundColor(0xff56649f);
}
}
} else {
......@@ -467,7 +485,8 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
wchar_t formatBuffer[2048];
myswprintf(formatBuffer, L"%d", sort_list[i]);
mainGame->stCardPos[i]->setText(formatBuffer);
} else mainGame->stCardPos[i]->setText(L"");
} else
mainGame->stCardPos[i]->setText(L"");
mainGame->stCardPos[i]->setBackgroundColor(0xff56649f);
}
mainGame->stCardPos[i]->setVisible(true);
......@@ -648,12 +667,12 @@ void ClientField::ShowSelectOption(int select_hint) {
mainGame->wOptions->setRelativePosition(pos);
mainGame->bgOptions->setRelativePosition(rect<s32>(0, 0, (scrollbar ? 405 : 390) * mainGame->xScale, pos.LowerRightCorner.Y - pos.UpperLeftCorner.Y));
} else {
mainGame->SetStaticText(mainGame->stOptions, 350 * mainGame->xScale, mainGame->guiFont,(wchar_t*)dataManager.GetDesc(select_options[0]));
mainGame->SetStaticText(mainGame->stOptions, 350 * mainGame->xScale, mainGame->guiFont,
(wchar_t*)dataManager.GetDesc(select_options[0]));
mainGame->stOptions->setVisible(true);
mainGame->btnOptionp->setVisible(false);
mainGame->btnOptionn->setVisible(count > 1);
mainGame->btnOptionOK->setVisible(true);
mainGame->scrOption->setVisible(false);
for(int i = 0; i < 5; i++)
mainGame->btnOption[i]->setVisible(false);
recti pos = mainGame->wOptions->getRelativePosition();
......
......@@ -46,6 +46,7 @@ public:
std::vector<ClientCard*> conti_cards;
std::vector<std::pair<int,int>> activatable_descs;
std::vector<int> select_options;
std::vector<int> select_options_index;
std::vector<ChainInfo> chains;
int extra_p_count[2];
......@@ -85,6 +86,7 @@ public:
bool last_chain;
bool deck_reversed;
bool conti_selecting;
bool cant_check_grave;
ClientField();
void Clear();
......@@ -145,6 +147,7 @@ public:
ClientCard* clicked_card;
ClientCard* command_card;
ClientCard* highlighting_card;
ClientCard* menu_card;
int list_command;
virtual bool OnEvent(const irr::SEvent& event);
......@@ -165,5 +168,6 @@ public:
//special cards
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
#define CARD_QUESTION 38723936
#endif //CLIENT_FIELD_H
This diff is collapsed.
......@@ -27,6 +27,11 @@ public:
void ClearSearch();
void SortList();
void RefreshDeckList();
void RefreshReadonly(int catesel);
void ChangeCategory(int catesel);
void ShowDeckManage();
bool CardNameContains(const wchar_t *haystack, const wchar_t *needle);
bool push_main(code_pointer pointer, int seq = -1);
......
This diff is collapsed.
......@@ -157,6 +157,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_HP_DUELIST: {
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true);
DuelClient::SendPacketToServer(CTOS_HS_TODUELIST);
break;
......@@ -494,7 +495,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
case BUTTON_CLOSE_SETTINGS: {
mainGame->HideElement(mainGame->wSettings);
mainGame->ShowElement(mainGame->wMainMenu);
break;
break;
}
}
break;
......@@ -604,6 +605,32 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
break;
}
case irr::gui::EGET_CHECKBOX_CHANGED: {
switch(id) {
case CHECKBOX_HP_READY: {
if(!caller->isEnabled())
break;
mainGame->env->setFocus(mainGame->wHostPrepare);
if(static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
static_cast<irr::gui::IGUICheckBox*>(caller)->setChecked(false);
break;
}
UpdateDeck();
DuelClient::SendPacketToServer(CTOS_HS_READY);
mainGame->cbCategorySelect->setEnabled(false);
mainGame->cbDeckSelect->setEnabled(false);
} else {
DuelClient::SendPacketToServer(CTOS_HS_NOTREADY);
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true);
}
break;
}
}
break;
}
case irr::gui::EGET_COMBO_BOX_CHANGED: {
switch(id) {
case COMBOBOX_BOT_RULE: {
......@@ -637,32 +664,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
break;
}
case irr::gui::EGET_CHECKBOX_CHANGED: {
switch(id) {
case CHECKBOX_HP_READY: {
if(!caller->isEnabled())
break;
mainGame->env->setFocus(mainGame->wHostPrepare);
if(static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
static_cast<irr::gui::IGUICheckBox*>(caller)->setChecked(false);
break;
}
UpdateDeck();
DuelClient::SendPacketToServer(CTOS_HS_READY);
mainGame->cbCategorySelect->setEnabled(false);
mainGame->cbDeckSelect->setEnabled(false);
} else {
DuelClient::SendPacketToServer(CTOS_HS_NOTREADY);
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true);
}
break;
}
}
break;
}
default: break;
}
break;
......
......@@ -74,12 +74,12 @@ public:
lpFileOp.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT;
return SHFileOperationW(&lpFileOp) == 0;
}
static bool DeleteDir(const char* dir) {
wchar_t wdir[1024];
BufferIO::DecodeUTF8(dir, wdir);
return DeleteDir(wdir);
}
wchar_t wdir[1024];
BufferIO::DecodeUTF8(dir, wdir);
return DeleteDir(wdir);
}
static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) {
wchar_t findstr[1024];
......@@ -142,46 +142,45 @@ public:
BufferIO::EncodeUTF8(wdir, dir);
return MakeDir(dir);
}
static bool Rename(const wchar_t* woldname, const wchar_t* wnewname) {
char oldname[1024];
char newname[1024];
BufferIO::EncodeUTF8(woldname, oldname);
BufferIO::EncodeUTF8(wnewname, newname);
return Rename(oldname, newname);
}
static bool Rename(const char* oldname, const char* newname) {
return rename(oldname, newname) == 0;
}
static bool DeleteDir(const wchar_t* wdir) {
char dir[1024];
BufferIO::EncodeUTF8(wdir, dir);
return DeleteDir(dir);
}
static bool DeleteDir(const char* dir) {
bool success = true;
TraversalDir(dir, [dir, &success](const char *name, bool isdir) {
char full_path[256];
sprintf(full_path, "%s/%s", dir, name);
if (isdir)
{
if(!DeleteDir(full_path))
success = false;
}
else
{
if(unlink(full_path) != 0)
success = false;
}
});
if (rmdir(dir) != 0)
success = false;
return success;
}
char oldname[1024];
char newname[1024];
BufferIO::EncodeUTF8(woldname, oldname);
BufferIO::EncodeUTF8(wnewname, newname);
return Rename(oldname, newname);
}
static bool Rename(const char* oldname, const char* newname) {
return rename(oldname, newname) == 0;
}
static bool DeleteDir(const wchar_t* wdir) {
char dir[1024];
BufferIO::EncodeUTF8(wdir, dir);
return DeleteDir(dir);
}
static bool DeleteDir(const char* dir) {
bool success = true;
TraversalDir(dir, [dir, &success](const char *name, bool isdir) {
char full_path[256];
sprintf(full_path, "%s/%s", dir, name);
if (isdir)
{
if(!DeleteDir(full_path))
success = false;
}
else
{
if(unlink(full_path) != 0)
success = false;
}
});
if (rmdir(dir) != 0)
success = false;
return success;
}
struct file_unit {
std::string filename;
......@@ -205,7 +204,7 @@ public:
funit.filename = std::string(dirp->d_name);
funit.is_dir = S_ISDIR(fileStat.st_mode);
if(funit.is_dir && (strcmp(dirp->d_name, ".") == 0 || strcmp(dirp->d_name, "..") == 0))
continue;
continue;
file_list.push_back(funit);
}
closedir(dir);
......
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