Commit c919fe4e authored by qq247321453's avatar qq247321453
parents 0c7cd5f7 47af2075
...@@ -288,8 +288,8 @@ bool ClientCard::deck_sort_def(code_pointer p1, code_pointer p2) { ...@@ -288,8 +288,8 @@ bool ClientCard::deck_sort_def(code_pointer p1, code_pointer p2) {
return p1->first < p2->first; return p1->first < p2->first;
} }
bool ClientCard::deck_sort_name(code_pointer p1, code_pointer p2) { bool ClientCard::deck_sort_name(code_pointer p1, code_pointer p2) {
const wchar_t* name1 = dataManager.GetName(p1->first); const wchar_t* name1 = mainGame->dataManager->GetName(p1->first);
const wchar_t* name2 = dataManager.GetName(p2->first); const wchar_t* name2 = mainGame->dataManager->GetName(p2->first);
int res = wcscmp(name1, name2); int res = wcscmp(name1, name2);
if(res != 0) if(res != 0)
return res < 0; return res < 0;
......
...@@ -447,7 +447,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) { ...@@ -447,7 +447,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
else if(conti_selecting) else if(conti_selecting)
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->chain_code)); mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->chain_code));
else else
mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i]->controler]); mainGame->btnCardSelect[i]->setImage(mainGame->imageManager->tCover[selectable_cards[i]->controler]);
mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>((startpos + i * 125) * mainGame->xScale, 65 * mainGame->yScale, (startpos + 120 + i * 125) * mainGame->xScale, 235 * mainGame->yScale)); mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>((startpos + i * 125) * mainGame->xScale, 65 * mainGame->yScale, (startpos + 120 + i * 125) * mainGame->xScale, 235 * mainGame->yScale));
mainGame->btnCardSelect[i]->setPressed(false); mainGame->btnCardSelect[i]->setPressed(false);
mainGame->btnCardSelect[i]->setVisible(true); mainGame->btnCardSelect[i]->setVisible(true);
...@@ -457,13 +457,13 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) { ...@@ -457,13 +457,13 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
if(conti_selecting) if(conti_selecting)
myswprintf(formatBuffer, L"%ls", DataManager::unknown_string); myswprintf(formatBuffer, L"%ls", DataManager::unknown_string);
else if(cant_check_grave && selectable_cards[i]->location == LOCATION_GRAVE) else if(cant_check_grave && selectable_cards[i]->location == LOCATION_GRAVE)
myswprintf(formatBuffer, L"%ls", dataManager.FormatLocation(selectable_cards[i]->location, 0)); myswprintf(formatBuffer, L"%ls", mainGame->dataManager->FormatLocation(selectable_cards[i]->location, 0));
else if(selectable_cards[i]->location == LOCATION_OVERLAY) else if(selectable_cards[i]->location == LOCATION_OVERLAY)
myswprintf(formatBuffer, L"%ls[%d](%d)", myswprintf(formatBuffer, L"%ls[%d](%d)",
dataManager.FormatLocation(selectable_cards[i]->overlayTarget->location, selectable_cards[i]->overlayTarget->sequence), mainGame->dataManager->FormatLocation(selectable_cards[i]->overlayTarget->location, selectable_cards[i]->overlayTarget->sequence),
selectable_cards[i]->overlayTarget->sequence + 1, selectable_cards[i]->sequence + 1); selectable_cards[i]->overlayTarget->sequence + 1, selectable_cards[i]->sequence + 1);
else else
myswprintf(formatBuffer, L"%ls[%d]", dataManager.FormatLocation(selectable_cards[i]->location, selectable_cards[i]->sequence), myswprintf(formatBuffer, L"%ls[%d]", mainGame->dataManager->FormatLocation(selectable_cards[i]->location, selectable_cards[i]->sequence),
selectable_cards[i]->sequence + 1); selectable_cards[i]->sequence + 1);
mainGame->stCardPos[i]->setText(formatBuffer); mainGame->stCardPos[i]->setText(formatBuffer);
// color // color
...@@ -535,12 +535,12 @@ void ClientField::ShowChainCard() { ...@@ -535,12 +535,12 @@ void ClientField::ShowChainCard() {
if(selectable_cards[i]->code) if(selectable_cards[i]->code)
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->code)); mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->code));
else else
mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i]->controler]); mainGame->btnCardSelect[i]->setImage(mainGame->imageManager->tCover[selectable_cards[i]->controler]);
mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>((startpos + i * 125) * mainGame->xScale, 65 * mainGame->yScale, (startpos + 120 + i * 125) * mainGame->xScale, 235 * mainGame->yScale)); mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>((startpos + i * 125) * mainGame->xScale, 65 * mainGame->yScale, (startpos + 120 + i * 125) * mainGame->xScale, 235 * mainGame->yScale));
mainGame->btnCardSelect[i]->setPressed(false); mainGame->btnCardSelect[i]->setPressed(false);
mainGame->btnCardSelect[i]->setVisible(true); mainGame->btnCardSelect[i]->setVisible(true);
wchar_t formatBuffer[2048]; wchar_t formatBuffer[2048];
myswprintf(formatBuffer, L"%ls[%d]", dataManager.FormatLocation(selectable_cards[i]->location, selectable_cards[i]->sequence), myswprintf(formatBuffer, L"%ls[%d]", mainGame->dataManager->FormatLocation(selectable_cards[i]->location, selectable_cards[i]->sequence),
selectable_cards[i]->sequence + 1); selectable_cards[i]->sequence + 1);
mainGame->stCardPos[i]->setText(formatBuffer); mainGame->stCardPos[i]->setText(formatBuffer);
if(selectable_cards[i]->location == LOCATION_OVERLAY) { if(selectable_cards[i]->location == LOCATION_OVERLAY) {
...@@ -592,17 +592,17 @@ void ClientField::ShowLocationCard() { ...@@ -592,17 +592,17 @@ void ClientField::ShowLocationCard() {
if(display_cards[i]->code) if(display_cards[i]->code)
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardDisplay[i], display_cards[i]->code)); mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardDisplay[i], display_cards[i]->code));
else else
mainGame->btnCardDisplay[i]->setImage(imageManager.tCover[display_cards[i]->controler]); mainGame->btnCardDisplay[i]->setImage(mainGame->imageManager->tCover[display_cards[i]->controler]);
mainGame->btnCardDisplay[i]->setRelativePosition(rect<s32>((startpos + i * 125) * mainGame->xScale, 65 * mainGame->yScale, (startpos + 120 + i * 125) * mainGame->xScale, 235 * mainGame->yScale)); mainGame->btnCardDisplay[i]->setRelativePosition(rect<s32>((startpos + i * 125) * mainGame->xScale, 65 * mainGame->yScale, (startpos + 120 + i * 125) * mainGame->xScale, 235 * mainGame->yScale));
mainGame->btnCardDisplay[i]->setPressed(false); mainGame->btnCardDisplay[i]->setPressed(false);
mainGame->btnCardDisplay[i]->setVisible(true); mainGame->btnCardDisplay[i]->setVisible(true);
wchar_t formatBuffer[2048]; wchar_t formatBuffer[2048];
if(display_cards[i]->location == LOCATION_OVERLAY) if(display_cards[i]->location == LOCATION_OVERLAY)
myswprintf(formatBuffer, L"%ls[%d](%d)", myswprintf(formatBuffer, L"%ls[%d](%d)",
dataManager.FormatLocation(display_cards[i]->overlayTarget->location, display_cards[i]->overlayTarget->sequence), mainGame->dataManager->FormatLocation(display_cards[i]->overlayTarget->location, display_cards[i]->overlayTarget->sequence),
display_cards[i]->overlayTarget->sequence + 1, display_cards[i]->sequence + 1); display_cards[i]->overlayTarget->sequence + 1, display_cards[i]->sequence + 1);
else else
myswprintf(formatBuffer, L"%ls[%d]", dataManager.FormatLocation(display_cards[i]->location, display_cards[i]->sequence), myswprintf(formatBuffer, L"%ls[%d]", mainGame->dataManager->FormatLocation(display_cards[i]->location, display_cards[i]->sequence),
display_cards[i]->sequence + 1); display_cards[i]->sequence + 1);
mainGame->stDisplayPos[i]->setText(formatBuffer); mainGame->stDisplayPos[i]->setText(formatBuffer);
if(display_cards[i]->location == LOCATION_OVERLAY) { if(display_cards[i]->location == LOCATION_OVERLAY) {
...@@ -651,13 +651,13 @@ void ClientField::ShowSelectOption(int select_hint) { ...@@ -651,13 +651,13 @@ void ClientField::ShowSelectOption(int select_hint) {
bool quickmode = true; bool quickmode = true;
mainGame->gMutex.lock(); mainGame->gMutex.lock();
for(auto option : select_options) { for(auto option : select_options) {
if(mainGame->guiFont->getDimension(dataManager.GetDesc(option)).Width > 370 * mainGame->xScale) { if(mainGame->guiFont->getDimension(mainGame->dataManager->GetDesc(option)).Width > 370 * mainGame->xScale) {
quickmode = false; quickmode = false;
break; break;
} }
} }
for(int i = 0; (i < count) && (i < 5) && quickmode; i++) { for(int i = 0; (i < count) && (i < 5) && quickmode; i++) {
const wchar_t* option = dataManager.GetDesc(select_options[i]); const wchar_t* option = mainGame->dataManager->GetDesc(select_options[i]);
mainGame->btnOption[i]->setText(option); mainGame->btnOption[i]->setText(option);
} }
if(quickmode) { if(quickmode) {
...@@ -681,7 +681,7 @@ void ClientField::ShowSelectOption(int select_hint) { ...@@ -681,7 +681,7 @@ void ClientField::ShowSelectOption(int select_hint) {
mainGame->bgOptions->setRelativePosition(rect<s32>(0, 0, (scrollbar ? 405 : 390) * mainGame->xScale, pos.LowerRightCorner.Y - pos.UpperLeftCorner.Y)); mainGame->bgOptions->setRelativePosition(rect<s32>(0, 0, (scrollbar ? 405 : 390) * mainGame->xScale, pos.LowerRightCorner.Y - pos.UpperLeftCorner.Y));
} else { } else {
mainGame->SetStaticText(mainGame->stOptions, 350 * mainGame->xScale, mainGame->guiFont, mainGame->SetStaticText(mainGame->stOptions, 350 * mainGame->xScale, mainGame->guiFont,
(wchar_t*)dataManager.GetDesc(select_options[0])); (wchar_t*)mainGame->dataManager->GetDesc(select_options[0]));
mainGame->stOptions->setVisible(true); mainGame->stOptions->setVisible(true);
mainGame->btnOptionp->setVisible(false); mainGame->btnOptionp->setVisible(false);
mainGame->btnOptionn->setVisible(count > 1); mainGame->btnOptionn->setVisible(count > 1);
...@@ -693,9 +693,9 @@ void ClientField::ShowSelectOption(int select_hint) { ...@@ -693,9 +693,9 @@ void ClientField::ShowSelectOption(int select_hint) {
mainGame->wOptions->setRelativePosition(pos); mainGame->wOptions->setRelativePosition(pos);
} }
if(select_hint) if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint)); myswprintf(textBuffer, L"%ls", mainGame->dataManager->GetDesc(select_hint));
else else
myswprintf(textBuffer, dataManager.GetSysString(555)); myswprintf(textBuffer, mainGame->dataManager->GetSysString(555));
mainGame->stOptions->setText(textBuffer); mainGame->stOptions->setText(textBuffer);
mainGame->PopupElement(mainGame->wOptions); mainGame->PopupElement(mainGame->wOptions);
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
...@@ -1139,9 +1139,9 @@ bool ClientField::ShowSelectSum(bool panelmode) { ...@@ -1139,9 +1139,9 @@ bool ClientField::ShowSelectSum(bool panelmode) {
select_ready = true; select_ready = true;
mainGame->wCardSelect->setVisible(false); mainGame->wCardSelect->setVisible(false);
wchar_t wbuf[256], *pwbuf = wbuf; wchar_t wbuf[256], *pwbuf = wbuf;
BufferIO::CopyWStrRef(dataManager.GetSysString(209), pwbuf, 256); BufferIO::CopyWStrRef(mainGame->dataManager->GetSysString(209), pwbuf, 256);
*pwbuf++ = L'\n'; *pwbuf++ = L'\n';
BufferIO::CopyWStrRef(dataManager.GetSysString(210), pwbuf, 256); BufferIO::CopyWStrRef(mainGame->dataManager->GetSysString(210), pwbuf, 256);
mainGame->stQMessage->setText(wbuf); mainGame->stQMessage->setText(wbuf);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
} }
...@@ -1160,9 +1160,9 @@ bool ClientField::ShowSelectSum(bool panelmode) { ...@@ -1160,9 +1160,9 @@ bool ClientField::ShowSelectSum(bool panelmode) {
} else { } else {
select_ready = true; select_ready = true;
wchar_t wbuf[256], *pwbuf = wbuf; wchar_t wbuf[256], *pwbuf = wbuf;
BufferIO::CopyWStrRef(dataManager.GetSysString(209), pwbuf, 256); BufferIO::CopyWStrRef(mainGame->dataManager->GetSysString(209), pwbuf, 256);
*pwbuf++ = L'\n'; *pwbuf++ = L'\n';
BufferIO::CopyWStrRef(dataManager.GetSysString(210), pwbuf, 256); BufferIO::CopyWStrRef(mainGame->dataManager->GetSysString(210), pwbuf, 256);
mainGame->stQMessage->setText(wbuf); mainGame->stQMessage->setText(wbuf);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
} }
...@@ -1539,7 +1539,7 @@ void ClientField::UpdateDeclarableList() { ...@@ -1539,7 +1539,7 @@ void ClientField::UpdateDeclarableList() {
int trycode = BufferIO::GetVal(pname); int trycode = BufferIO::GetVal(pname);
CardString cstr; CardString cstr;
CardData cd; CardData cd;
if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd) && is_declarable(cd, declare_opcodes)) { if(mainGame->dataManager->GetString(trycode, &cstr) && mainGame->dataManager->GetData(trycode, &cd) && is_declarable(cd, declare_opcodes)) {
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
mainGame->lstANCard->addItem(cstr.name.c_str()); mainGame->lstANCard->addItem(cstr.name.c_str());
...@@ -1553,7 +1553,7 @@ void ClientField::UpdateDeclarableList() { ...@@ -1553,7 +1553,7 @@ void ClientField::UpdateDeclarableList() {
int selcode = (sel == -1) ? 0 : cache[sel]; int selcode = (sel == -1) ? 0 : cache[sel];
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
for(const auto& trycode : cache) { for(const auto& trycode : cache) {
if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd) && is_declarable(cd, declare_opcodes)) { if(mainGame->dataManager->GetString(trycode, &cstr) && mainGame->dataManager->GetData(trycode, &cd) && is_declarable(cd, declare_opcodes)) {
ancard.push_back(trycode); ancard.push_back(trycode);
mainGame->lstANCard->addItem(cstr.name.c_str()); mainGame->lstANCard->addItem(cstr.name.c_str());
if(trycode == selcode) if(trycode == selcode)
...@@ -1565,9 +1565,9 @@ void ClientField::UpdateDeclarableList() { ...@@ -1565,9 +1565,9 @@ void ClientField::UpdateDeclarableList() {
} }
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) { for(auto cit = mainGame->dataManager->_strings.begin(); cit != mainGame->dataManager->_strings.end(); ++cit) {
if(cit->second.name.find(pname) != std::wstring::npos) { if(cit->second.name.find(pname) != std::wstring::npos) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings auto cp = mainGame->dataManager->GetCodePointer(cit->first); //verified by _strings
//datas.alias can be double card names or alias //datas.alias can be double card names or alias
if(is_declarable(cp->second, declare_opcodes)) { if(is_declarable(cp->second, declare_opcodes)) {
if(pname == cit->second.name) { //exact match if(pname == cit->second.name) { //exact match
......
...@@ -7,7 +7,6 @@ namespace ygo { ...@@ -7,7 +7,6 @@ namespace ygo {
const wchar_t* DataManager::unknown_string = L"???"; const wchar_t* DataManager::unknown_string = L"???";
byte DataManager::scriptBuffer[0x20000]; byte DataManager::scriptBuffer[0x20000];
IFileSystem* DataManager::FileSystem; IFileSystem* DataManager::FileSystem;
DataManager dataManager;
bool DataManager::LoadDB(const wchar_t* wfile) { bool DataManager::LoadDB(const wchar_t* wfile) {
char file[256]; char file[256];
...@@ -358,7 +357,7 @@ const wchar_t* DataManager::FormatLinkMarker(int link_marker) { ...@@ -358,7 +357,7 @@ const wchar_t* DataManager::FormatLinkMarker(int link_marker) {
return lmBuffer; return lmBuffer;
} }
int DataManager::CardReader(int code, void* pData) { int DataManager::CardReader(int code, void* pData) {
if(!dataManager.GetData(code, (CardData*)pData)) if(!mainGame->dataManager->GetData(code, (CardData*)pData))
memset(pData, 0, sizeof(CardData)); memset(pData, 0, sizeof(CardData));
return 0; return 0;
} }
......
...@@ -64,8 +64,6 @@ public: ...@@ -64,8 +64,6 @@ public:
static IFileSystem* FileSystem; static IFileSystem* FileSystem;
}; };
extern DataManager dataManager;
} }
#endif // DATAMANAGER_H #endif // DATAMANAGER_H
This diff is collapsed.
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
namespace ygo { namespace ygo {
DeckManager deckManager;
void DeckManager::LoadLFListSingle(const char* path) { void DeckManager::LoadLFListSingle(const char* path) {
LFList* cur = nullptr; LFList* cur = nullptr;
FILE* fp = fopen(path, "r"); FILE* fp = fopen(path, "r");
...@@ -63,7 +61,7 @@ const wchar_t* DeckManager::GetLFListName(int lfhash) { ...@@ -63,7 +61,7 @@ const wchar_t* DeckManager::GetLFListName(int lfhash) {
}); });
if(lit != _lfList.end()) if(lit != _lfList.end())
return lit->listName.c_str(); return lit->listName.c_str();
return dataManager.unknown_string; return mainGame->dataManager->unknown_string;
} }
std::unordered_map<int, int>* DeckManager::GetLFListContent(int lfhash) { std::unordered_map<int, int>* DeckManager::GetLFListContent(int lfhash) {
auto lit = std::find_if(_lfList.begin(), _lfList.end(), [lfhash](const ygo::LFList& list) { auto lit = std::find_if(_lfList.begin(), _lfList.end(), [lfhash](const ygo::LFList& list) {
...@@ -149,7 +147,7 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec) { ...@@ -149,7 +147,7 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec) {
CardData cd; CardData cd;
for(int i = 0; i < mainc; ++i) { for(int i = 0; i < mainc; ++i) {
code = dbuf[i]; code = dbuf[i];
if(!dataManager.GetData(code, &cd)) { if(!mainGame->dataManager->GetData(code, &cd)) {
errorcode = code; errorcode = code;
continue; continue;
} }
...@@ -158,21 +156,21 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec) { ...@@ -158,21 +156,21 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec) {
else if(cd.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) { else if(cd.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) {
if(deck.extra.size() >= 15) if(deck.extra.size() >= 15)
continue; continue;
deck.extra.push_back(dataManager.GetCodePointer(code)); //verified by GetData() deck.extra.push_back(mainGame->dataManager->GetCodePointer(code)); //verified by GetData()
} else if(deck.main.size() < 60) { } else if(deck.main.size() < 60) {
deck.main.push_back(dataManager.GetCodePointer(code)); deck.main.push_back(mainGame->dataManager->GetCodePointer(code));
} }
} }
for(int i = 0; i < sidec; ++i) { for(int i = 0; i < sidec; ++i) {
code = dbuf[mainc + i]; code = dbuf[mainc + i];
if(!dataManager.GetData(code, &cd)) { if(!mainGame->dataManager->GetData(code, &cd)) {
errorcode = code; errorcode = code;
continue; continue;
} }
if(cd.type & TYPE_TOKEN) if(cd.type & TYPE_TOKEN)
continue; continue;
if(deck.side.size() < 15) if(deck.side.size() < 15)
deck.side.push_back(dataManager.GetCodePointer(code)); //verified by GetData() deck.side.push_back(mainGame->dataManager->GetCodePointer(code)); //verified by GetData()
} }
return errorcode; return errorcode;
} }
......
...@@ -54,9 +54,6 @@ public: ...@@ -54,9 +54,6 @@ public:
bool DeleteCategory(const wchar_t* name); bool DeleteCategory(const wchar_t* name);
int TypeCount(std::vector<code_pointer> list, unsigned int ctype); int TypeCount(std::vector<code_pointer> list, unsigned int ctype);
}; };
extern DeckManager deckManager;
} }
#endif //DECKMANAGER_H #endif //DECKMANAGER_H
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "deck_con.h" #include "deck_con.h"
#include "menu_handler.h" #include "menu_handler.h"
#include "sound_manager.h" #include "sound_manager.h"
#include "deck_manager.h"
#include "image_manager.h"
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <list> #include <list>
...@@ -127,7 +129,7 @@ struct FadingUnit { ...@@ -127,7 +129,7 @@ struct FadingUnit {
irr::core::vector2di fadingDiff; irr::core::vector2di fadingDiff;
}; };
class Game :IProcessEventReceiver{ class Game{
public: public:
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
...@@ -152,7 +154,7 @@ public: ...@@ -152,7 +154,7 @@ public:
void DrawBackGround(); void DrawBackGround();
void DrawSelField(int player, int loc, size_t seq, irr::video::ITexture* texture, bool reverse = false, bool spin = false); void DrawSelField(int player, int loc, size_t seq, irr::video::ITexture* texture, bool reverse = false, bool spin = false);
void DrawLinkedZones(ClientCard* pcard, ClientCard* fcard = 0); void DrawLinkedZones(ClientCard* pcard, ClientCard* fcard = 0);
void CheckMutual(ClientCard* pcard, int mark); void CheckMutual(ClientCard* pcard, int mark){}
void DrawCards(); void DrawCards();
void DrawCard(ClientCard* pcard); void DrawCard(ClientCard* pcard);
void DrawShadowText(irr::gui::CGUITTFont* font, const core::stringw& text, const core::rect<s32>& position, const core::rect<s32>& padding, video::SColor color = 0xffffffff, video::SColor shadowcolor = 0xff000000, bool hcenter = false, bool vcenter = false, const core::rect<s32>* clip = 0); void DrawShadowText(irr::gui::CGUITTFont* font, const core::stringw& text, const core::rect<s32>& position, const core::rect<s32>& padding, video::SColor color = 0xffffffff, video::SColor shadowcolor = 0xff000000, bool hcenter = false, bool vcenter = false, const core::rect<s32>* clip = 0);
...@@ -206,6 +208,9 @@ public: ...@@ -206,6 +208,9 @@ public:
// don't merge // don't merge
std::unique_ptr<SoundManager> soundManager; std::unique_ptr<SoundManager> soundManager;
std::unique_ptr<DeckManager> deckManager;
std::unique_ptr<ImageManager> imageManager;
std::unique_ptr<DataManager> dataManager;
std::mutex gMutex; std::mutex gMutex;
Signal frameSignal; Signal frameSignal;
Signal actionSignal; Signal actionSignal;
...@@ -657,27 +662,6 @@ public: ...@@ -657,27 +662,6 @@ public:
Signal externalSignal; Signal externalSignal;
static void onHandleAndroidCommand(ANDROID_APP app, int32_t cmd); static void onHandleAndroidCommand(ANDROID_APP app, int32_t cmd);
#endif #endif
void setPositionFix(core::position2di fix){
InputFix = fix;
}
float optX(float x) {
float x2 = x - InputFix.X;
if (x2 < 0) {
return 0;
}
return x2;
}
float optY(float y) {
float y2 = y - InputFix.Y;
if (y2 < 0) {
return 0;
}
return y2;
}
void process(irr::SEvent &event);
private:
core::position2di InputFix;
}; };
extern Game *mainGame; extern Game *mainGame;
......
...@@ -40,17 +40,18 @@ int GetListBoxIndex(IGUIListBox* listbox, const wchar_t * target){ ...@@ -40,17 +40,18 @@ int GetListBoxIndex(IGUIListBox* listbox, const wchar_t * target){
return -1; return -1;
} }
void android_main(ANDROID_APP app) { void android_main(ANDROID_APP app) {
app->inputPollSource.process = android::process_input;
app_dummy();
#else #else
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
#endif #endif
evthread_use_pthreads(); evthread_use_pthreads();
ygo::Game _game; auto game = new ygo::Game;
ygo::mainGame = &_game; if(ygo::mainGame != nullptr){
delete ygo::mainGame;
}
ygo::mainGame = game;
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
android::InitOptions *options = android::getInitOptions(app); android::InitOptions *options = android::getInitOptions(app);
if(!ygo::mainGame->Initialize(app, options)){ if(!game->Initialize(app, options)){
delete options; delete options;
return; return;
} }
...@@ -78,29 +79,29 @@ int main(int argc, char* argv[]) { ...@@ -78,29 +79,29 @@ int main(int argc, char* argv[]) {
wchar_t fname[1024]; wchar_t fname[1024];
char* tmp = sub_string(arg, 2); char* tmp = sub_string(arg, 2);
BufferIO::DecodeUTF8(tmp, fname); BufferIO::DecodeUTF8(tmp, fname);
ygo::dataManager.LoadDB(fname); game->dataManager->LoadDB(fname);
delete tmp; delete tmp;
} else if(!strcmp(arg, "-k")) { // Keep on return } else if(!strcmp(arg, "-k")) { // Keep on return
exit_on_return = false; exit_on_return = false;
keep_on_return = true; keep_on_return = true;
} else if(!strcmp(arg, "-c")) { // Create host } else if(!strcmp(arg, "-c")) { // Create host
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu); game->HideElement(game->wMainMenu);
ClickButton(ygo::mainGame->btnJoinHost); ClickButton(game->btnJoinHost);
break; break;
} else if(!strcmp(arg, "-j")) { // Join host } else if(!strcmp(arg, "-j")) { // Join host
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu); game->HideElement(game->wMainMenu);
ClickButton(ygo::mainGame->btnJoinHost); ClickButton(game->btnJoinHost);
break; break;
} else if(!strcmp(arg, "-r")) { // Replay } else if(!strcmp(arg, "-r")) { // Replay
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
//显示录像窗口 //显示录像窗口
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu); game->HideElement(game->wMainMenu);
ygo::mainGame->ShowElement(ygo::mainGame->wReplay); game->ShowElement(game->wReplay);
ygo::mainGame->ebRepStartTurn->setText(L"1"); game->ebRepStartTurn->setText(L"1");
ygo::mainGame->stReplayInfo->setText(L""); game->stReplayInfo->setText(L"");
ygo::mainGame->RefreshReplay(); game->RefreshReplay();
int index = -1; int index = -1;
if((i+1) < argc){//下一个参数是录像名 if((i+1) < argc){//下一个参数是录像名
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
...@@ -111,24 +112,24 @@ int main(int argc, char* argv[]) { ...@@ -111,24 +112,24 @@ int main(int argc, char* argv[]) {
wchar_t fname[1024]; wchar_t fname[1024];
BufferIO::DecodeUTF8(name, fname); BufferIO::DecodeUTF8(name, fname);
index = GetListBoxIndex(ygo::mainGame->lstReplayList, fname); index = GetListBoxIndex(game->lstReplayList, fname);
ALOGD("open replay file:index=%d, name=%s", index, name); ALOGD("open replay file:index=%d, name=%s", index, name);
} }
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu); game->HideElement(game->wMainMenu);
ClickButton(ygo::mainGame->btnReplayMode); ClickButton(game->btnReplayMode);
if (index >= 0) { if (index >= 0) {
ygo::mainGame->lstReplayList->setSelected(index); game->lstReplayList->setSelected(index);
ClickButton(ygo::mainGame->btnLoadReplay); ClickButton(game->btnLoadReplay);
} }
break;//只播放一个 break;//只播放一个
} else if(!strcmp(arg, "-s")) { // Single } else if(!strcmp(arg, "-s")) { // Single
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
//显示残局窗口 //显示残局窗口
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu); game->HideElement(game->wMainMenu);
ygo::mainGame->ShowElement(ygo::mainGame->wSinglePlay); game->ShowElement(game->wSinglePlay);
ygo::mainGame->RefreshSingleplay(); game->RefreshSingleplay();
ygo::mainGame->RefreshBot(); game->RefreshBot();
int index = -1; int index = -1;
if((i+1) < argc){//下一个参数是文件名 if((i+1) < argc){//下一个参数是文件名
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
...@@ -138,12 +139,12 @@ int main(int argc, char* argv[]) { ...@@ -138,12 +139,12 @@ int main(int argc, char* argv[]) {
#endif #endif
wchar_t fname[1024]; wchar_t fname[1024];
BufferIO::DecodeUTF8(name, fname); BufferIO::DecodeUTF8(name, fname);
index = GetListBoxIndex(ygo::mainGame->lstSinglePlayList, fname); index = GetListBoxIndex(game->lstSinglePlayList, fname);
ALOGD("open single file:index=%d, name=%s", index, name); ALOGD("open single file:index=%d, name=%s", index, name);
} }
if(index >= 0){ if(index >= 0){
ygo::mainGame->lstSinglePlayList->setSelected(index); game->lstSinglePlayList->setSelected(index);
ClickButton(ygo::mainGame->btnLoadSinglePlay); ClickButton(game->btnLoadSinglePlay);
} }
break; break;
} }
...@@ -151,8 +152,8 @@ int main(int argc, char* argv[]) { ...@@ -151,8 +152,8 @@ int main(int argc, char* argv[]) {
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
delete options; delete options;
#endif #endif
ygo::mainGame->externalSignal.Set(); game->externalSignal.Set();
ygo::mainGame->externalSignal.SetNoWait(true); game->externalSignal.SetNoWait(true);
ygo::mainGame->MainLoop(); game->MainLoop();
return; return;
} }
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
namespace ygo { namespace ygo {
ImageManager imageManager;
bool ImageManager::Initial(const path dir) { bool ImageManager::Initial(const path dir) {
tCover[0] = driver->getTexture((dir + path("/textures/cover.jpg")).c_str()); tCover[0] = driver->getTexture((dir + path("/textures/cover.jpg")).c_str());
tCover[1] = driver->getTexture((dir + path("/textures/cover2.jpg")).c_str()); tCover[1] = driver->getTexture((dir + path("/textures/cover2.jpg")).c_str());
......
...@@ -80,8 +80,6 @@ public: ...@@ -80,8 +80,6 @@ public:
std::list<std::string> support_types; std::list<std::string> support_types;
}; };
extern ImageManager imageManager;
} }
#endif // IMAGEMANAGER_H #endif // IMAGEMANAGER_H
...@@ -23,14 +23,14 @@ void UpdateDeck() { ...@@ -23,14 +23,14 @@ void UpdateDeck() {
char deckbuf[1024]; char deckbuf[1024];
char* pdeck = deckbuf; char* pdeck = deckbuf;
BufferIO::WriteInt32(pdeck, deckManager.current_deck.main.size() + deckManager.current_deck.extra.size()); BufferIO::WriteInt32(pdeck, mainGame->deckManager->current_deck.main.size() + mainGame->deckManager->current_deck.extra.size());
BufferIO::WriteInt32(pdeck, deckManager.current_deck.side.size()); BufferIO::WriteInt32(pdeck, mainGame->deckManager->current_deck.side.size());
for(size_t i = 0; i < deckManager.current_deck.main.size(); ++i) for(size_t i = 0; i < mainGame->deckManager->current_deck.main.size(); ++i)
BufferIO::WriteInt32(pdeck, deckManager.current_deck.main[i]->first); BufferIO::WriteInt32(pdeck, mainGame->deckManager->current_deck.main[i]->first);
for(size_t i = 0; i < deckManager.current_deck.extra.size(); ++i) for(size_t i = 0; i < mainGame->deckManager->current_deck.extra.size(); ++i)
BufferIO::WriteInt32(pdeck, deckManager.current_deck.extra[i]->first); BufferIO::WriteInt32(pdeck, mainGame->deckManager->current_deck.extra[i]->first);
for(size_t i = 0; i < deckManager.current_deck.side.size(); ++i) for(size_t i = 0; i < mainGame->deckManager->current_deck.side.size(); ++i)
BufferIO::WriteInt32(pdeck, deckManager.current_deck.side[i]->first); BufferIO::WriteInt32(pdeck, mainGame->deckManager->current_deck.side[i]->first);
DuelClient::SendBufferToServer(CTOS_UPDATE_DECK, deckbuf, pdeck - deckbuf); DuelClient::SendBufferToServer(CTOS_UPDATE_DECK, deckbuf, pdeck - deckbuf);
} }
bool MenuHandler::OnEvent(const irr::SEvent& event) { bool MenuHandler::OnEvent(const irr::SEvent& event) {
...@@ -99,7 +99,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -99,7 +99,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(status != 0) { if(status != 0) {
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->soundManager->PlaySoundEffect(SoundManager::SFX::INFO); mainGame->soundManager->PlaySoundEffect(SoundManager::SFX::INFO);
mainGame->addMessageBox(L"", dataManager.GetSysString(1412)); mainGame->addMessageBox(L"", mainGame->dataManager->GetSysString(1412));
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
break; break;
} else { } else {
...@@ -181,7 +181,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -181,7 +181,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_HP_READY: { case BUTTON_HP_READY: {
if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 || if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) { !mainGame->deckManager->LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
break; break;
} }
UpdateDeck(); UpdateDeck();
...@@ -266,7 +266,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -266,7 +266,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
mainGame->gMutex.lock(); mainGame->gMutex.lock();
wchar_t textBuffer[256]; wchar_t textBuffer[256];
myswprintf(textBuffer, L"%ls\n%ls", mainGame->lstReplayList->getListItem(sel), dataManager.GetSysString(1363)); myswprintf(textBuffer, L"%ls\n%ls", mainGame->lstReplayList->getListItem(sel), mainGame->dataManager->GetSysString(1363));
mainGame->SetStaticText(mainGame->stQMessage, 370 * mainGame->xScale, mainGame->textFont, textBuffer); mainGame->SetStaticText(mainGame->stQMessage, 370 * mainGame->xScale, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
...@@ -296,7 +296,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -296,7 +296,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(sel == -1) if(sel == -1)
break; break;
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->wReplaySave->setText(dataManager.GetSysString(1364)); mainGame->wReplaySave->setText(mainGame->dataManager->GetSysString(1364));
mainGame->ebRSName->setText(mainGame->lstReplayList->getListItem(sel)); mainGame->ebRSName->setText(mainGame->lstReplayList->getListItem(sel));
mainGame->PopupElement(mainGame->wReplaySave); mainGame->PopupElement(mainGame->wReplaySave);
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
...@@ -334,15 +334,15 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -334,15 +334,15 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int main = replay.ReadInt32(); int main = replay.ReadInt32();
Deck tmp_deck; Deck tmp_deck;
for(int j = 0; j < main; ++j) for(int j = 0; j < main; ++j)
tmp_deck.main.push_back(dataManager.GetCodePointer(replay.ReadInt32())); tmp_deck.main.push_back(mainGame->dataManager->GetCodePointer(replay.ReadInt32()));
int extra = replay.ReadInt32(); int extra = replay.ReadInt32();
for(int j = 0; j < extra; ++j) for(int j = 0; j < extra; ++j)
tmp_deck.extra.push_back(dataManager.GetCodePointer(replay.ReadInt32())); tmp_deck.extra.push_back(mainGame->dataManager->GetCodePointer(replay.ReadInt32()));
FileSystem::SafeFileName(namebuf[i]); FileSystem::SafeFileName(namebuf[i]);
myswprintf(filename, L"deck/%ls-%d %ls.ydk", ex_filename, i + 1, namebuf[i]); myswprintf(filename, L"deck/%ls-%d %ls.ydk", ex_filename, i + 1, namebuf[i]);
deckManager.SaveDeck(tmp_deck, filename); mainGame->deckManager->SaveDeck(tmp_deck, filename);
} }
mainGame->stACMessage->setText(dataManager.GetSysString(1335)); mainGame->stACMessage->setText(mainGame->dataManager->GetSysString(1335));
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
break; break;
} }
...@@ -367,7 +367,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -367,7 +367,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wchar_t arg1[512]; wchar_t arg1[512];
if(mainGame->botInfo[sel].select_deckfile) { if(mainGame->botInfo[sel].select_deckfile) {
wchar_t botdeck[256]; wchar_t botdeck[256];
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck); mainGame->deckManager->GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
myswprintf(arg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck); myswprintf(arg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck);
} }
else else
...@@ -385,7 +385,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -385,7 +385,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wchar_t warg1[512]; wchar_t warg1[512];
if(mainGame->botInfo[sel].select_deckfile) { if(mainGame->botInfo[sel].select_deckfile) {
wchar_t botdeck[256]; wchar_t botdeck[256];
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck); mainGame->deckManager->GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
myswprintf(warg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck); myswprintf(warg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck);
} }
else else
...@@ -412,7 +412,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -412,7 +412,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wchar_t warg1[512]; wchar_t warg1[512];
if(mainGame->botInfo[sel].select_deckfile) { if(mainGame->botInfo[sel].select_deckfile) {
wchar_t botdeck[256]; wchar_t botdeck[256];
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck); mainGame->deckManager->GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
myswprintf(warg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck); myswprintf(warg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck);
} }
else else
...@@ -456,7 +456,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -456,7 +456,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
case BUTTON_DECK_EDIT: { case BUTTON_DECK_EDIT: {
mainGame->RefreshCategoryDeck(mainGame->cbDBCategory, mainGame->cbDBDecks); mainGame->RefreshCategoryDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
if(mainGame->cbDBCategory->getSelected() != -1 && mainGame->cbDBDecks->getSelected() != -1) { if(mainGame->cbDBCategory->getSelected() != -1 && mainGame->cbDBDecks->getSelected() != -1) {
deckManager.LoadDeck(mainGame->cbDBCategory, mainGame->cbDBDecks); mainGame->deckManager->LoadDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
mainGame->ebDeckname->setText(L""); mainGame->ebDeckname->setText(L"");
} }
mainGame->HideElement(mainGame->wMainMenu); mainGame->HideElement(mainGame->wMainMenu);
...@@ -492,7 +492,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -492,7 +492,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(Replay::RenameReplay(mainGame->lstReplayList->getListItem(prev_sel), newname)) { if(Replay::RenameReplay(mainGame->lstReplayList->getListItem(prev_sel), newname)) {
mainGame->lstReplayList->setItem(prev_sel, newname, -1); mainGame->lstReplayList->setItem(prev_sel, newname, -1);
} else { } else {
mainGame->addMessageBox(L"", dataManager.GetSysString(1365)); mainGame->addMessageBox(L"", mainGame->dataManager->GetSysString(1365));
} }
} }
prev_operation = 0; prev_operation = 0;
...@@ -635,7 +635,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -635,7 +635,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->env->setFocus(mainGame->wHostPrepare); mainGame->env->setFocus(mainGame->wHostPrepare);
if(static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) { if(static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 || if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) { !mainGame->deckManager->LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
static_cast<irr::gui::IGUICheckBox*>(caller)->setChecked(false); static_cast<irr::gui::IGUICheckBox*>(caller)->setChecked(false);
break; break;
} }
......
#include "netserver.h" #include "netserver.h"
#include "single_duel.h" #include "single_duel.h"
#include "tag_duel.h" #include "tag_duel.h"
#include "game.h"
namespace ygo { namespace ygo {
std::unordered_map<bufferevent*, DuelPlayer> NetServer::users; std::unordered_map<bufferevent*, DuelPlayer> NetServer::users;
...@@ -238,14 +239,14 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) { ...@@ -238,14 +239,14 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) {
if(pkt->info.mode > 2) if(pkt->info.mode > 2)
pkt->info.mode = 0; pkt->info.mode = 0;
unsigned int hash = 1; unsigned int hash = 1;
for(auto lfit = deckManager._lfList.begin(); lfit != deckManager._lfList.end(); ++lfit) { for(auto lfit = mainGame->deckManager->_lfList.begin(); lfit != mainGame->deckManager->_lfList.end(); ++lfit) {
if(pkt->info.lflist == lfit->hash) { if(pkt->info.lflist == lfit->hash) {
hash = pkt->info.lflist; hash = pkt->info.lflist;
break; break;
} }
} }
if(hash == 1) if(hash == 1)
pkt->info.lflist = deckManager._lfList[0].hash; pkt->info.lflist = mainGame->deckManager->_lfList[0].hash;
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
HostInfo tmp; HostInfo tmp;
memcpy(&tmp, &pkt->info, sizeof(struct HostInfo)); memcpy(&tmp, &pkt->info, sizeof(struct HostInfo));
......
...@@ -244,7 +244,7 @@ void ReplayMode::EndDuel() { ...@@ -244,7 +244,7 @@ void ReplayMode::EndDuel() {
if(!is_closing) { if(!is_closing) {
mainGame->actionSignal.Reset(); mainGame->actionSignal.Reset();
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->stMessage->setText(dataManager.GetSysString(1501)); mainGame->stMessage->setText(mainGame->dataManager->GetSysString(1501));
mainGame->HideElement(mainGame->wCardSelect); mainGame->HideElement(mainGame->wCardSelect);
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
......
...@@ -251,7 +251,7 @@ void SingleDuel::PlayerReady(DuelPlayer* dp, bool is_ready) { ...@@ -251,7 +251,7 @@ void SingleDuel::PlayerReady(DuelPlayer* dp, bool is_ready) {
if(deck_error[dp->type]) { if(deck_error[dp->type]) {
deckerror = (DECKERROR_UNKNOWNCARD << 28) + deck_error[dp->type]; deckerror = (DECKERROR_UNKNOWNCARD << 28) + deck_error[dp->type];
} else { } else {
deckerror = deckManager.CheckDeck(pdeck[dp->type], host_info.lflist, host_info.rule); deckerror = mainGame->deckManager->CheckDeck(pdeck[dp->type], host_info.lflist, host_info.rule);
} }
} }
if(deckerror) { if(deckerror) {
...@@ -295,9 +295,9 @@ void SingleDuel::UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len) { ...@@ -295,9 +295,9 @@ void SingleDuel::UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len) {
return; return;
} }
if(duel_count == 0) { if(duel_count == 0) {
deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec); deck_error[dp->type] = mainGame->deckManager->LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec);
} else { } else {
if(deckManager.LoadSide(pdeck[dp->type], (int*)deckbuf, mainc, sidec)) { if(mainGame->deckManager->LoadSide(pdeck[dp->type], (int*)deckbuf, mainc, sidec)) {
ready[dp->type] = true; ready[dp->type] = true;
NetServer::SendPacketToPlayer(dp, STOC_DUEL_START); NetServer::SendPacketToPlayer(dp, STOC_DUEL_START);
if(ready[0] && ready[1]) { if(ready[0] && ready[1]) {
......
...@@ -75,7 +75,7 @@ int SingleMode::SinglePlayThread() { ...@@ -75,7 +75,7 @@ int SingleMode::SinglePlayThread() {
mainGame->wInfos->setVisible(true); mainGame->wInfos->setVisible(true);
mainGame->wPallet->setVisible(true); mainGame->wPallet->setVisible(true);
mainGame->btnLeaveGame->setVisible(true); mainGame->btnLeaveGame->setVisible(true);
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1210)); mainGame->btnLeaveGame->setText(mainGame->dataManager->GetSysString(1210));
mainGame->wPhase->setVisible(true); mainGame->wPhase->setVisible(true);
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->dInfo.isFirst = true; mainGame->dInfo.isFirst = true;
...@@ -122,7 +122,7 @@ int SingleMode::SinglePlayThread() { ...@@ -122,7 +122,7 @@ int SingleMode::SinglePlayThread() {
wcsftime(timetext, 40, L"%Y-%m-%d %H-%M-%S", localedtime); wcsftime(timetext, 40, L"%Y-%m-%d %H-%M-%S", localedtime);
mainGame->ebRSName->setText(timetext); mainGame->ebRSName->setText(timetext);
if(!mainGame->chkAutoSaveReplay->isChecked()) { if(!mainGame->chkAutoSaveReplay->isChecked()) {
mainGame->wReplaySave->setText(dataManager.GetSysString(1340)); mainGame->wReplaySave->setText(mainGame->dataManager->GetSysString(1340));
mainGame->PopupElement(mainGame->wReplaySave); mainGame->PopupElement(mainGame->wReplaySave);
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
mainGame->replaySignal.Reset(); mainGame->replaySignal.Reset();
...@@ -130,7 +130,7 @@ int SingleMode::SinglePlayThread() { ...@@ -130,7 +130,7 @@ int SingleMode::SinglePlayThread() {
} else { } else {
mainGame->actionParam = 1; mainGame->actionParam = 1;
wchar_t msgbuf[256]; wchar_t msgbuf[256];
myswprintf(msgbuf, dataManager.GetSysString(1367), timetext); myswprintf(msgbuf, mainGame->dataManager->GetSysString(1367), timetext);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, msgbuf); mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, msgbuf);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
......
...@@ -151,7 +151,7 @@ void SoundManager::StopBGM() { ...@@ -151,7 +151,7 @@ void SoundManager::StopBGM() {
} }
bool SoundManager::PlayChant(unsigned int code) { bool SoundManager::PlayChant(unsigned int code) {
CardData cd; CardData cd;
if(dataManager.GetData(code, &cd) && (cd.alias != 0)) if(mainGame->dataManager->GetData(code, &cd) && (cd.alias != 0))
code = cd.alias; code = cd.alias;
if(ChantsList.count(code) && bgm_PlayingName != ChantsList[code]) { if(ChantsList.count(code) && bgm_PlayingName != ChantsList[code]) {
......
...@@ -226,7 +226,7 @@ void TagDuel::PlayerReady(DuelPlayer* dp, bool is_ready) { ...@@ -226,7 +226,7 @@ void TagDuel::PlayerReady(DuelPlayer* dp, bool is_ready) {
if(deck_error[dp->type]) { if(deck_error[dp->type]) {
deckerror = (DECKERROR_UNKNOWNCARD << 28) + deck_error[dp->type]; deckerror = (DECKERROR_UNKNOWNCARD << 28) + deck_error[dp->type];
} else { } else {
deckerror = deckManager.CheckDeck(pdeck[dp->type], host_info.lflist, host_info.rule); deckerror = mainGame->deckManager->CheckDeck(pdeck[dp->type], host_info.lflist, host_info.rule);
} }
} }
if(deckerror) { if(deckerror) {
...@@ -269,7 +269,7 @@ void TagDuel::UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len) { ...@@ -269,7 +269,7 @@ void TagDuel::UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len) {
NetServer::SendPacketToPlayer(dp, STOC_ERROR_MSG, scem); NetServer::SendPacketToPlayer(dp, STOC_ERROR_MSG, scem);
return; return;
} }
deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec); deck_error[dp->type] = mainGame->deckManager->LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec);
} }
void TagDuel::StartDuel(DuelPlayer* dp) { void TagDuel::StartDuel(DuelPlayer* dp) {
if(dp != host_player) if(dp != host_player)
......
...@@ -121,8 +121,8 @@ namespace ygo { ...@@ -121,8 +121,8 @@ namespace ygo {
} }
} }
void Utils::changeCursor(irr::gui::ECURSOR_ICON icon) { void Utils::changeCursor(irr::IrrlichtDevice* device, irr::gui::ECURSOR_ICON icon) {
irr::gui::ICursorControl* cursor = mainGame->device->getCursorControl(); irr::gui::ICursorControl* cursor = device->getCursorControl();
if (cursor->getActiveIcon() != icon) { if (cursor->getActiveIcon() != icon) {
cursor->setActiveIcon(icon); cursor->setActiveIcon(icon);
} }
...@@ -205,8 +205,8 @@ namespace ygo { ...@@ -205,8 +205,8 @@ namespace ygo {
return res; return res;
} }
irr::io::IReadFile* Utils::FindandOpenFileFromArchives(const path_string & path, const path_string & name) { irr::io::IReadFile* Utils::FindandOpenFileFromArchives(std::vector<Utils::IrrArchiveHelper> archives, const path_string & path, const path_string & name) {
for(auto& archive : mainGame->archives) { for(auto& archive : archives) {
int res = -1; int res = -1;
Utils::FindfolderFiles(archive, path, [match = &name, &res](int index, path_string name, bool isdir, void* payload)->bool { Utils::FindfolderFiles(archive, path, [match = &name, &res](int index, path_string name, bool isdir, void* payload)->bool {
if(isdir) if(isdir)
......
...@@ -35,13 +35,12 @@ namespace ygo { ...@@ -35,13 +35,12 @@ namespace ygo {
static bool Deletedirectory(const path_string& source); static bool Deletedirectory(const path_string& source);
static void CreateResourceFolders(); static void CreateResourceFolders();
static void takeScreenshot(irr::IrrlichtDevice* device); static void takeScreenshot(irr::IrrlichtDevice* device);
static void ToggleFullscreen(); static void changeCursor(irr::IrrlichtDevice* device, irr::gui::ECURSOR_ICON icon);
static void changeCursor(irr::gui::ECURSOR_ICON icon);
static void FindfolderFiles(const path_string& path, const std::function<void(path_string, bool, void*)>& cb, void* payload = nullptr); static void FindfolderFiles(const path_string& path, const std::function<void(path_string, bool, void*)>& cb, void* payload = nullptr);
static std::vector<path_string> FindfolderFiles(const path_string& path, std::vector<path_string> extensions, int subdirectorylayers = 0); static std::vector<path_string> FindfolderFiles(const path_string& path, std::vector<path_string> extensions, int subdirectorylayers = 0);
static void FindfolderFiles(IrrArchiveHelper& archive, const path_string& path, const std::function<bool(int, path_string, bool, void*)>& cb, void* payload = nullptr); static void FindfolderFiles(IrrArchiveHelper& archive, const path_string& path, const std::function<bool(int, path_string, bool, void*)>& cb, void* payload = nullptr);
static std::vector<int> FindfolderFiles(IrrArchiveHelper& archive, const path_string& path, std::vector<path_string> extensions, int subdirectorylayers = 0); static std::vector<int> FindfolderFiles(IrrArchiveHelper& archive, const path_string& path, std::vector<path_string> extensions, int subdirectorylayers = 0);
static irr::io::IReadFile* FindandOpenFileFromArchives(const path_string& path, const path_string& name); static irr::io::IReadFile* FindandOpenFileFromArchives(std::vector<Utils::IrrArchiveHelper> archives, const path_string& path, const path_string& name);
static std::wstring NormalizePath(std::wstring path, bool trailing_slash = true); static std::wstring NormalizePath(std::wstring path, bool trailing_slash = true);
static std::wstring GetFileExtension(std::wstring file); static std::wstring GetFileExtension(std::wstring file);
static std::wstring GetFilePath(std::wstring file); static std::wstring GetFilePath(std::wstring file);
......
...@@ -2,12 +2,15 @@ ...@@ -2,12 +2,15 @@
buildscript { buildscript {
repositories { repositories {
maven { url 'https://maven.aliyun.com/repository/public'}
maven { url 'https://maven.aliyun.com/repository/google'}
jcenter() jcenter()
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.2.1' classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle-experimental:0.11.1'
//classpath 'me.tatarka:gradle-retrolambda:3.2.5' //classpath 'me.tatarka:gradle-retrolambda:3.2.5'
} }
} }
...@@ -20,6 +23,8 @@ ext { ...@@ -20,6 +23,8 @@ ext {
allprojects { allprojects {
repositories { repositories {
maven { url 'https://maven.aliyun.com/repository/public'}
maven { url 'https://maven.aliyun.com/repository/google'}
jcenter() jcenter()
google() google()
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true # org.gradle.parallel=true
#Mon Aug 31 19:03:54 CST 2020 #Mon Aug 31 19:03:54 CST 2020
org.gradle.jvmargs=-Xmx4096M -Dkotlin.daemon.jvm.options="-Xmx4096M"
org.gradle.parallel=true
android.enableJetifier=true android.enableJetifier=true
android.useAndroidX=true android.useAndroidX=true
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
android.injected.testOnly=false android.injected.testOnly=false
\ No newline at end of file
...@@ -749,9 +749,9 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) { ...@@ -749,9 +749,9 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) {
app->activity->vm->DetachCurrentThread(); app->activity->vm->DetachCurrentThread();
} }
core::position2di initJavaBridge(ANDROID_APP app, void* handle) { void initJavaBridge(ANDROID_APP app, void* handle) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return core::position2di(0, 0); return;
JNIEnv* jni = nullptr; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
jobject lNativeActivity = app->activity->clazz; jobject lNativeActivity = app->activity->clazz;
...@@ -760,18 +760,9 @@ core::position2di initJavaBridge(ANDROID_APP app, void* handle) { ...@@ -760,18 +760,9 @@ core::position2di initJavaBridge(ANDROID_APP app, void* handle) {
"setNativeHandle", "(J)V"); "setNativeHandle", "(J)V");
jlong code = (jlong) handle; jlong code = (jlong) handle;
jni->CallVoidMethod(lNativeActivity, MethodSetHandle, code); jni->CallVoidMethod(lNativeActivity, MethodSetHandle, code);
jmethodID methodX = jni->GetMethodID(ClassNativeActivity,
"getPositionX", "()I");
jint posX = jni->CallIntMethod(lNativeActivity, methodX);
jmethodID methodY = jni->GetMethodID(ClassNativeActivity,
"getPositionY", "()I");
jint posY = jni->CallIntMethod(lNativeActivity, methodY);
jni->DeleteLocalRef(ClassNativeActivity); jni->DeleteLocalRef(ClassNativeActivity);
app->activity->vm->DetachCurrentThread(); app->activity->vm->DetachCurrentThread();
__android_log_print(ANDROID_LOG_INFO, "ygo", "Android command initJavaBridge posX=%d, posY=%d", posX, posY); __android_log_print(ANDROID_LOG_INFO, "ygo", "Android command initJavaBridge");
return core::position2di((int)posX, (int)posY);
} }
InitOptions* getInitOptions(ANDROID_APP app) { InitOptions* getInitOptions(ANDROID_APP app) {
...@@ -869,30 +860,6 @@ void toggleOverlayView(ANDROID_APP app, bool pShow) { ...@@ -869,30 +860,6 @@ void toggleOverlayView(ANDROID_APP app, bool pShow) {
app->activity->vm->DetachCurrentThread(); app->activity->vm->DetachCurrentThread();
} }
void process_input(ANDROID_APP app,
struct android_poll_source* source) {
AInputEvent* event = NULL;
if (AInputQueue_getEvent(app->inputQueue, &event) >= 0) {
int type = AInputEvent_getType(event);
bool skip_predispatch = AInputEvent_getType(event)
== AINPUT_EVENT_TYPE_KEY
&& AKeyEvent_getKeyCode(event) == AKEYCODE_BACK;
// skip predispatch (all it does is send to the IME)
if (!skip_predispatch
&& AInputQueue_preDispatchEvent(app->inputQueue, event)) {
return;
}
int32_t handled = 0;
if (app->onInputEvent != NULL)
handled = app->onInputEvent(app, event);
AInputQueue_finishEvent(app->inputQueue, event, handled);
} else {
// LOGE("Failure reading next input event: %s\n", strerror(errno));
}
}
void onGameExit(ANDROID_APP app){ void onGameExit(ANDROID_APP app){
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return; return;
......
...@@ -126,7 +126,7 @@ extern void toggleGlobalIME(ANDROID_APP app, bool pShow); ...@@ -126,7 +126,7 @@ extern void toggleGlobalIME(ANDROID_APP app, bool pShow);
extern void toggleIME(ANDROID_APP app, bool pShow, const char* hint); extern void toggleIME(ANDROID_APP app, bool pShow, const char* hint);
//Init Java Irrlicht world. //Init Java Irrlicht world.
extern core::position2di initJavaBridge(ANDROID_APP app, void* handle); extern void initJavaBridge(ANDROID_APP app, void* handle);
//Cause a haptic feedback. //Cause a haptic feedback.
extern void perfromHapticFeedback(ANDROID_APP app); extern void perfromHapticFeedback(ANDROID_APP app);
...@@ -186,10 +186,6 @@ extern bool getFontAntiAlias(ANDROID_APP app); ...@@ -186,10 +186,6 @@ extern bool getFontAntiAlias(ANDROID_APP app);
extern void showAndroidComboBoxCompat(ANDROID_APP app, bool pShow, extern void showAndroidComboBoxCompat(ANDROID_APP app, bool pShow,
char** pContents, int count, int mode = 0); char** pContents, int count, int mode = 0);
/* android event handlers*/
extern void process_input(ANDROID_APP app,
struct android_poll_source* source);
extern s32 handleInput(ANDROID_APP app, AInputEvent* androidEvent); extern s32 handleInput(ANDROID_APP app, AInputEvent* androidEvent);
extern bool android_deck_delete(const char* deck_name); extern bool android_deck_delete(const char* deck_name);
......
...@@ -294,14 +294,6 @@ static void* join_game_thread(void* param) { ...@@ -294,14 +294,6 @@ static void* join_game_thread(void* param) {
} }
} }
JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetInputFix(
JNIEnv* env, jclass clazz, jlong handle, jint x, jint y) {
if(ygo::mainGame) {
ALOGD("setInputFix posX=%d, posY=%d", x, y);
ygo::mainGame->setPositionFix(core::position2di(x, y));
}
}
static void* cancel_chain_thread(void* param) { static void* cancel_chain_thread(void* param) {
IrrlichtDevice* device = (IrrlichtDevice*) param; IrrlichtDevice* device = (IrrlichtDevice*) param;
irr::os::Printer::log("before send cancel chain"); irr::os::Printer::log("before send cancel chain");
......
package cn.garymb.ygomobile.controller;
import android.os.Looper;
import android.util.Log;
import android.view.InputEvent;
import android.view.InputQueue;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import cn.garymb.ygomobile.utils.AndroidHideApi;
/**
* 仅测试安卓7-11
*/
public class InputQueueCompat implements InvocationHandler {
private static final String TAG = "kk-java";
private static Constructor<InputQueue> InputQueue_ctr;
private static Method getNativePtr_method;
private static Class<?> FinishedInputEventCallback_class;
//sendInputEvent(InputEvent e, Object token, boolean predispatch,
// FinishedInputEventCallback callback)
private static Method sendInputEvent_method;
private FinishedInputEventCallbackCompat finishedInputEventCallbackCompat;
static {
AndroidHideApi.enableHideApi();
try {
Looper.getMainLooper();
InputQueue_ctr = InputQueue.class.getDeclaredConstructor();
// InputQueue_ctr.setAccessible(true);
getNativePtr_method = InputQueue.class.getMethod("getNativePtr");
// getNativePtr_method.setAccessible(true);
FinishedInputEventCallback_class = Class.forName(InputQueue.class.getName() + "$FinishedInputEventCallback");
sendInputEvent_method = InputQueue.class.getMethod("sendInputEvent", InputEvent.class, Object.class, boolean.class,
FinishedInputEventCallback_class);
} catch (Throwable e) {
Log.e(TAG, "InputQueueCompat init", e);
}
}
private final InputQueue inputQueue;
private final Object callback;
public InputQueueCompat(InputQueue inputQueue) {
this.inputQueue = inputQueue;
if(inputQueue != null) {
callback = Proxy.newProxyInstance(InputQueue.class.getClassLoader(), new Class[]{FinishedInputEventCallback_class},
this);
} else {
callback = null;
}
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) {
//void onFinishedInputEvent(Object token, boolean handled);
if ("onFinishedInputEvent".equals(method.getName())) {
Object token = args[0];
boolean handled = (boolean) args[1];
onFinishedInputEvent(token, handled);
return 0;
}
return 0;
}
public InputQueueCompat() {
this(create());
}
public void setFinishedInputEventCallback(FinishedInputEventCallbackCompat finishedInputEventCallbackCompat) {
this.finishedInputEventCallbackCompat = finishedInputEventCallbackCompat;
}
public boolean isValid() {
return inputQueue != null && sendInputEvent_method != null && getNativePtr_method != null;
}
private static InputQueue create() {
try {
return InputQueue_ctr.newInstance();
} catch (Throwable e) {
Log.w(TAG, "InputQueue<init>", e);
return null;
}
}
public long getNativePtr() {
if (getNativePtr_method == null || inputQueue == null) {
return 0;
}
try {
Long ret = (Long) getNativePtr_method.invoke(inputQueue);
if (ret == null) {
return 0;
}
return ret;
} catch (Throwable e) {
Log.w(TAG, "getNativePtr", e);
return 0;
}
}
public InputQueue getInputQueue() {
return inputQueue;
}
public void sendInputEvent(InputEvent e, Object token, boolean predispatch) {
if (sendInputEvent_method == null) {
return;
}
try {
Log.d(TAG, "inputQueue:sendInputEvent:" + e);
sendInputEvent_method.invoke(inputQueue, e, token, predispatch, callback);
} catch (Throwable ex) {
Log.w(TAG, "inputQueue:sendInputEvent", ex);
}
}
public void onFinishedInputEvent(Object token, boolean handled) {
//TODO
Log.d(TAG, "onFinishedInputEvent:" + token + ", handled=" + handled);
if(this.finishedInputEventCallbackCompat != null){
finishedInputEventCallbackCompat.onFinishedInputEvent(token, handled);
}
}
public interface FinishedInputEventCallbackCompat{
void onFinishedInputEvent(Object token, boolean handled);
}
}
package cn.garymb.ygomobile.core;
import android.annotation.SuppressLint;
import android.app.NativeActivity;
import android.os.Bundle;
import android.util.Log;
import android.util.Size;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.FrameLayout;
import cn.garymb.ygomobile.controller.InputQueueCompat;
public abstract class GameActivity extends NativeActivity {
protected FrameLayout mLayout;
protected SurfaceView mSurfaceView;
private boolean replaced = false;
//自定义surface,方便控制窗口大小
private static final boolean USE_SURFACE = true;
//精准触摸事件
private static final boolean USE_MY_INPUT = true;
protected InputQueueCompat inputQueueCompat;
@Override
protected final void onCreate(Bundle savedInstanceState) {
if (USE_SURFACE) {
mSurfaceView = new SurfaceView(this);
}
if (USE_MY_INPUT) {
inputQueueCompat = new InputQueueCompat();
if (!inputQueueCompat.isValid()) {
inputQueueCompat = null;
}
}
initBeforeOnCreate();
super.onCreate(savedInstanceState);
initAfterOnCreate();
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
if (hasFocus) {
if (inputQueueCompat != null) {
super.onInputQueueCreated(inputQueueCompat.getInputQueue());
}
} else {
if (inputQueueCompat != null) {
super.onInputQueueDestroyed(inputQueueCompat.getInputQueue());
}
}
super.onWindowFocusChanged(hasFocus);
}
@SuppressLint("ClickableViewAccessibility")
@Override
public void setContentView(View view) {
Size size = getGameWindowSize();
mLayout = new FrameLayout(this);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(size.getWidth(), size.getHeight());
// mLayout.setBackgroundColor(Color.BLACK);
lp.gravity = Gravity.CENTER;
if (USE_SURFACE) {
mLayout.addView(mSurfaceView, lp);
mLayout.addView(view, lp);
super.setContentView(mLayout);
// app().attachGame(this);
// changeGameSize();
getWindow().takeSurface(null);
if (USE_MY_INPUT && inputQueueCompat != null) {
getWindow().takeInputQueue(null);
}
replaced = true;
mSurfaceView.getHolder().addCallback(this);
mSurfaceView.requestFocus();
getWindow().setGravity(Gravity.CENTER);
if (USE_MY_INPUT && inputQueueCompat != null) {
Log.d(IrrlichtBridge.TAG, "use java input queue:" + inputQueueCompat.getNativePtr());
mSurfaceView.setOnTouchListener((v, event) -> {
onSurfaceTouch(v, event);
return true;
});
}
} else {
mLayout.addView(view, lp);
getWindow().setGravity(Gravity.CENTER);
super.setContentView(mLayout);
}
}
protected void onSurfaceTouch(View v, MotionEvent event){
if (inputQueueCompat != null) {
inputQueueCompat.sendInputEvent(event, v, true);
}
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (USE_SURFACE) {
if (!replaced) {
return;
}
}
super.surfaceCreated(holder);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
if (USE_SURFACE) {
if (!replaced) {
return;
}
}
super.surfaceChanged(holder, format, width, height);
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if (USE_SURFACE) {
if (!replaced) {
return;
}
}
super.surfaceDestroyed(holder);
}
@Override
public void surfaceRedrawNeeded(SurfaceHolder holder) {
if (USE_SURFACE) {
if (!replaced) {
return;
}
}
super.surfaceRedrawNeeded(holder);
}
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if(inputQueueCompat != null) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// inputQueueCompat.sendInputEvent(event, this, true);
// return true;
// }
// }
// return super.onKeyDown(keyCode, event);
// }
//
// @Override
// public boolean onKeyUp(int keyCode, KeyEvent event) {
// if(inputQueueCompat != null) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// inputQueueCompat.sendInputEvent(event, this, true);
// return true;
// }
// }
// return super.onKeyUp(keyCode, event);
// }
protected abstract Size getGameWindowSize();
protected abstract void initBeforeOnCreate();
protected abstract void initAfterOnCreate();
}
...@@ -82,8 +82,6 @@ public final class IrrlichtBridge { ...@@ -82,8 +82,6 @@ public final class IrrlichtBridge {
private static native void nativeJoinGame(long handle, ByteBuffer buffer, int length); private static native void nativeJoinGame(long handle, ByteBuffer buffer, int length);
private static native void nativeSetInputFix(long handle, int x, int y);
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
public static void setArgs(Intent intent, String[] args) { public static void setArgs(Intent intent, String[] args) {
...@@ -155,10 +153,6 @@ public final class IrrlichtBridge { ...@@ -155,10 +153,6 @@ public final class IrrlichtBridge {
} }
} }
public static void setInputFix(int x, int y) {
nativeSetInputFix(sNativeHandle, x, y);
}
public static void cancelChain() { public static void cancelChain() {
nativeCancelChain(sNativeHandle); nativeCancelChain(sNativeHandle);
} }
...@@ -244,10 +238,6 @@ public final class IrrlichtBridge { ...@@ -244,10 +238,6 @@ public final class IrrlichtBridge {
void setNativeHandle(long nativeHandle); void setNativeHandle(long nativeHandle);
int getPositionX();
int getPositionY();
void onGameExit(); void onGameExit();
} }
} }
package cn.garymb.ygomobile.utils;
import android.os.Build;
import java.lang.reflect.Method;
public class AndroidHideApi {
private static boolean sBypassedP = false;
public static void enableHideApi() {
if (sBypassedP) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
try {
Method forNameMethod = Class.class.getDeclaredMethod("forName", String.class);
Class<?> clazz = (Class<?>) forNameMethod.invoke(null, "dalvik.system.VMRuntime");
Method getMethodMethod = Class.class.getDeclaredMethod("getDeclaredMethod", String.class, Class[].class);
Method getRuntime = (Method) getMethodMethod.invoke(clazz, "getRuntime", new Class[0]);
Method setHiddenApiExemptions = (Method) getMethodMethod.invoke(clazz, "setHiddenApiExemptions", new Class[]{String[].class});
Object runtime = getRuntime.invoke(null);
setHiddenApiExemptions.invoke(runtime, new Object[]{
new String[]{
"Landroid/",
"Lcom/android/",
"Ljava/lang/",
"Ldalvik/system/",
"Llibcore/io/",
"Lhuawei/"
}
});
} catch (Throwable e) {
e.printStackTrace();
}
}
sBypassedP = true;
}
}
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="combobox_choose_item">请选择其中一个</string> <string name="combobox_choose_item">하나를 선택하십시오 </string>
<string name="ignore_chain">忽略时点</string> <string name="ignore_chain">시점 무시 </string>
<string name="react_chain">显示时点</string> <string name="react_chain">표시 시간 </string>
<string name="refresh_textures">刷新界面</string> <string name="refresh_textures">인터페이스 새로 고침 </string>
<string name="tip_exit_game">게임을 종료하려면 뒤로 버튼을 다시 클릭하십시오. </string>
</resources> </resources>
\ No newline at end of file
...@@ -4,4 +4,5 @@ ...@@ -4,4 +4,5 @@
<string name="ignore_chain">忽略时点</string> <string name="ignore_chain">忽略时点</string>
<string name="react_chain">显示时点</string> <string name="react_chain">显示时点</string>
<string name="refresh_textures">刷新界面</string> <string name="refresh_textures">刷新界面</string>
<string name="tip_exit_game">再次点击返回键退出游戏</string>
</resources> </resources>
\ No newline at end of file
...@@ -5,4 +5,5 @@ ...@@ -5,4 +5,5 @@
<string name="ignore_chain">Ignore All Timing</string> <string name="ignore_chain">Ignore All Timing</string>
<string name="react_chain">Show All Timing</string> <string name="react_chain">Show All Timing</string>
<string name="refresh_textures">Refresh Textures</string> <string name="refresh_textures">Refresh Textures</string>
<string name="tip_exit_game">Click the BACK key again to exit the game </string>
</resources> </resources>
\ No newline at end of file
...@@ -64,6 +64,16 @@ public class App extends GameApplication { ...@@ -64,6 +64,16 @@ public class App extends GameApplication {
public float getYScale() { public float getYScale() {
return AppsSettings.get().getYScale(getGameWidth(), getGameHeight()); return AppsSettings.get().getYScale(getGameWidth(), getGameHeight());
} }
//
// @Override
// public int getGameHeight() {
// return 720;
// }
//
// @Override
// public int getGameWidth() {
// return 1280;
// }
@Override @Override
public String getCardImagePath() { public String getCardImagePath() {
......
...@@ -3,6 +3,7 @@ package cn.garymb.ygomobile; ...@@ -3,6 +3,7 @@ package cn.garymb.ygomobile;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.Point; import android.graphics.Point;
import android.os.ParcelFileDescriptor;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.WindowManager; import android.view.WindowManager;
...@@ -18,9 +19,11 @@ import java.util.Arrays; ...@@ -18,9 +19,11 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import cn.garymb.ygomobile.core.IrrlichtBridge;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.preference.PreferenceFragmentPlus; import cn.garymb.ygomobile.ui.preference.PreferenceFragmentPlus;
import cn.garymb.ygomobile.utils.DeckUtil; import cn.garymb.ygomobile.utils.DeckUtil;
import cn.garymb.ygomobile.utils.DensityUtils;
import cn.garymb.ygomobile.utils.IOUtils; import cn.garymb.ygomobile.utils.IOUtils;
import static cn.garymb.ygomobile.Constants.CORE_DECK_PATH; import static cn.garymb.ygomobile.Constants.CORE_DECK_PATH;
...@@ -33,6 +36,7 @@ import static cn.garymb.ygomobile.Constants.DEF_PREF_KEEP_SCALE; ...@@ -33,6 +36,7 @@ import static cn.garymb.ygomobile.Constants.DEF_PREF_KEEP_SCALE;
import static cn.garymb.ygomobile.Constants.DEF_PREF_NOTCH_HEIGHT; import static cn.garymb.ygomobile.Constants.DEF_PREF_NOTCH_HEIGHT;
import static cn.garymb.ygomobile.Constants.DEF_PREF_ONLY_GAME; import static cn.garymb.ygomobile.Constants.DEF_PREF_ONLY_GAME;
import static cn.garymb.ygomobile.Constants.DEF_PREF_READ_EX; import static cn.garymb.ygomobile.Constants.DEF_PREF_READ_EX;
import static cn.garymb.ygomobile.Constants.DEF_PREF_WINDOW_TOP_BOTTOM;
import static cn.garymb.ygomobile.Constants.PREF_DEF_IMMERSIVE_MODE; import static cn.garymb.ygomobile.Constants.PREF_DEF_IMMERSIVE_MODE;
import static cn.garymb.ygomobile.Constants.PREF_DEF_SENSOR_REFRESH; import static cn.garymb.ygomobile.Constants.PREF_DEF_SENSOR_REFRESH;
import static cn.garymb.ygomobile.Constants.PREF_FONT_SIZE; import static cn.garymb.ygomobile.Constants.PREF_FONT_SIZE;
...@@ -43,6 +47,7 @@ import static cn.garymb.ygomobile.Constants.PREF_NOTCH_HEIGHT; ...@@ -43,6 +47,7 @@ import static cn.garymb.ygomobile.Constants.PREF_NOTCH_HEIGHT;
import static cn.garymb.ygomobile.Constants.PREF_ONLY_GAME; import static cn.garymb.ygomobile.Constants.PREF_ONLY_GAME;
import static cn.garymb.ygomobile.Constants.PREF_READ_EX; import static cn.garymb.ygomobile.Constants.PREF_READ_EX;
import static cn.garymb.ygomobile.Constants.PREF_SENSOR_REFRESH; import static cn.garymb.ygomobile.Constants.PREF_SENSOR_REFRESH;
import static cn.garymb.ygomobile.Constants.PREF_WINDOW_TOP_BOTTOM;
import static cn.garymb.ygomobile.Constants.WINDBOT_DECK_PATH; import static cn.garymb.ygomobile.Constants.WINDBOT_DECK_PATH;
import static cn.garymb.ygomobile.Constants.WINDBOT_PATH; import static cn.garymb.ygomobile.Constants.WINDBOT_PATH;
import static cn.garymb.ygomobile.Constants.YDK_FILE_EX; import static cn.garymb.ygomobile.Constants.YDK_FILE_EX;
...@@ -53,8 +58,8 @@ public class AppsSettings { ...@@ -53,8 +58,8 @@ public class AppsSettings {
private static AppsSettings sAppsSettings; private static AppsSettings sAppsSettings;
private final Point mScreenSize = new Point(); private final Point mScreenSize = new Point();
private final Point mRealScreenSize = new Point(); private final Point mRealScreenSize = new Point();
private Context context; private final Context context;
private PreferenceFragmentPlus.SharedPreferencesPlus mSharedPreferences; private final PreferenceFragmentPlus.SharedPreferencesPlus mSharedPreferences;
private float mDensity; private float mDensity;
private AppsSettings(Context context) { private AppsSettings(Context context) {
...@@ -134,6 +139,7 @@ public class AppsSettings { ...@@ -134,6 +139,7 @@ public class AppsSettings {
} }
public float getXScale(int w, int h) { public float getXScale(int w, int h) {
//曲面屏
if (isKeepScale()) { if (isKeepScale()) {
float sx = getScreenHeight() / w; float sx = getScreenHeight() / w;
float sy = getScreenWidth() / h; float sy = getScreenWidth() / h;
...@@ -156,6 +162,15 @@ public class AppsSettings { ...@@ -156,6 +162,15 @@ public class AppsSettings {
return mSharedPreferences.getBoolean(PREF_KEEP_SCALE, DEF_PREF_KEEP_SCALE); return mSharedPreferences.getBoolean(PREF_KEEP_SCALE, DEF_PREF_KEEP_SCALE);
} }
public int getScreenPadding() {
//ListPreference都是string
String str = mSharedPreferences.getString(PREF_WINDOW_TOP_BOTTOM, null);
if (!TextUtils.isEmpty(str) && TextUtils.isDigitsOnly(str)) {
return Integer.parseInt(str);
}
return 0;
}
public float getScreenWidth() { public float getScreenWidth() {
int w, h; int w, h;
if (isImmerSiveMode()) { if (isImmerSiveMode()) {
...@@ -165,7 +180,11 @@ public class AppsSettings { ...@@ -165,7 +180,11 @@ public class AppsSettings {
w = mScreenSize.x; w = mScreenSize.x;
h = mScreenSize.y; h = mScreenSize.y;
} }
return Math.min(w, h); int ret = Math.min(w, h);
//测试代码,曲面屏左右2变需要留空白,但是游戏画面比例不对,需要修改c那边代码
int fix_h = DensityUtils.dp2px(context, getScreenPadding());
Log.d(IrrlichtBridge.TAG, "screen padding=" + fix_h);
return ret - fix_h * 2;
} }
public float getScreenHeight() { public float getScreenHeight() {
...@@ -518,7 +537,8 @@ public class AppsSettings { ...@@ -518,7 +537,8 @@ public class AppsSettings {
} }
//获得最后卡组绝对路径 //获得最后卡组绝对路径
public @Nullable String getLastDeckPath() { public @Nullable
String getLastDeckPath() {
String path; String path;
if (TextUtils.equals(context.getString(R.string.category_pack), getLastCategory())) { if (TextUtils.equals(context.getString(R.string.category_pack), getLastCategory())) {
path = getResourcePath() + "/" + CORE_PACK_PATH + "/" + getLastDeckName() + YDK_FILE_EX; path = getResourcePath() + "/" + CORE_PACK_PATH + "/" + getLastDeckName() + YDK_FILE_EX;
...@@ -677,8 +697,9 @@ public class AppsSettings { ...@@ -677,8 +697,9 @@ public class AppsSettings {
mSharedPreferences.putString(Constants.PREF_LAST_ROOM_LIST, array.toString()); mSharedPreferences.putString(Constants.PREF_LAST_ROOM_LIST, array.toString());
} }
@Deprecated
//获取收藏文件 //获取收藏文件
public String getFavoriteTxt() { public File getFavoriteFile() {
return new File(getResourcePath(), "/favorite.txt").getAbsolutePath(); return new File(getResourcePath(), "/favorite.txt");
} }
} }
...@@ -117,6 +117,10 @@ public interface Constants { ...@@ -117,6 +117,10 @@ public interface Constants {
String PREF_KEEP_SCALE = "pref_settings_keep_scale"; String PREF_KEEP_SCALE = "pref_settings_keep_scale";
boolean DEF_PREF_KEEP_SCALE = false; boolean DEF_PREF_KEEP_SCALE = false;
//dp单位,游戏高度减少,留空白
String PREF_WINDOW_TOP_BOTTOM = "pref_settings_window_top_bottom";
int DEF_PREF_WINDOW_TOP_BOTTOM = 0;
int REQUEST_CUT_IMG = 0x1000 + 0x10; int REQUEST_CUT_IMG = 0x1000 + 0x10;
int REQUEST_CHOOSE_FILE = 0x1000 + 0x20; int REQUEST_CHOOSE_FILE = 0x1000 + 0x20;
int REQUEST_CHOOSE_IMG = 0x1000 + 0x21; int REQUEST_CHOOSE_IMG = 0x1000 + 0x21;
......
package cn.garymb.ygomobile.loader;
import android.text.TextUtils;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import cn.garymb.ygomobile.core.IrrlichtBridge;
import ocgcore.DataManager;
import ocgcore.data.Card;
public class CardKeyWord {
private final String word;
private final List<ICardFilter> filterList = new ArrayList<>();
private final boolean empty;
public CardKeyWord(String word) {
this.word = word;
if (!TextUtils.isEmpty(word)) {
if (TextUtils.isDigitsOnly(word)) {
//搜索卡密
filterList.add(new CodeFilter(Long.parseLong(word)));
} else {
String[] ws = word.split(" ");
for (String w : ws) {
if (TextUtils.isEmpty(w)) {
continue;
}
boolean exclude = false;
if (w.startsWith("-")) {
exclude = true;
w = w.substring(1);
}
boolean onlyText = false;
if (w.startsWith("\"") || w.startsWith("“") || w.startsWith("”")) {
//只搜索文字
onlyText = true;
if (w.endsWith("\"") || w.endsWith("“") || w.endsWith("”")) {
w = w.substring(1, w.length() - 1);
} else {
w = w.substring(1);
}
}
if (!onlyText) {
long setcode = DataManager.get().getStringManager().getSetCode(w);
if (setcode != 0) {
//如果是系列名
filterList.add(new SetcodeFilter(setcode, exclude));
}
}
// Log.d(IrrlichtBridge.TAG, "filter:word=" + w + ", exclude=" + exclude + ", onlyText=" + onlyText);
filterList.add(new NameFilter(w, exclude));
}
}
}
empty = filterList.size() == 0;
}
public String getValue() {
return word;
}
public boolean isValid(Card card) {
if (empty) {
return true;
}
for (ICardFilter filter : filterList) {
if (!filter.isValid(card)) {
return false;
}
}
return true;
}
private static class NameFilter implements ICardFilter {
private final boolean exclude;
private final String word;
public NameFilter(String word, boolean exclude) {
this.exclude = exclude;
this.word = word;
}
@Override
public boolean isValid(Card card) {
if (exclude) {
return !card.Name.contains(word);
} else {
return card.Name.contains(word);
}
}
}
private static class SetcodeFilter implements ICardFilter {
private final boolean exclude;
private final long setcode;
public SetcodeFilter(long setcode, boolean exclude) {
this.exclude = exclude;
this.setcode = setcode;
}
@Override
public boolean isValid(Card card) {
if (exclude) {
return !card.isSetCode(setcode);
} else {
return card.isSetCode(setcode);
}
}
}
private static class CodeFilter implements ICardFilter {
private final long code;
public CodeFilter(long code) {
this.code = code;
}
@Override
public boolean isValid(Card card) {
return card.Code == code || card.Alias == code;
}
}
}
...@@ -91,7 +91,7 @@ public class CardLoader implements ICardSearcher { ...@@ -91,7 +91,7 @@ public class CardLoader implements ICardSearcher {
} }
public void loadData() { public void loadData() {
loadData(null); loadData(null, null);
} }
@Override @Override
...@@ -114,7 +114,7 @@ public class CardLoader implements ICardSearcher { ...@@ -114,7 +114,7 @@ public class CardLoader implements ICardSearcher {
} }
} }
private void loadData(CardSearchInfo searchInfo) { private void loadData(CardSearchInfo searchInfo, List<Integer> inCards) {
if (!isOpen()) { if (!isOpen()) {
return; return;
} }
...@@ -129,7 +129,11 @@ public class CardLoader implements ICardSearcher { ...@@ -129,7 +129,11 @@ public class CardLoader implements ICardSearcher {
List<Card> list = new ArrayList<>(); List<Card> list = new ArrayList<>();
for (int i = 0; i < cards.size(); i++) { for (int i = 0; i < cards.size(); i++) {
Card card = cards.valueAt(i); Card card = cards.valueAt(i);
if (searchInfo == null || searchInfo.check(card)) { //指定搜索范围
if (inCards != null && (!inCards.contains(card.Code) && !inCards.contains(card.Alias))) {
continue;
}
if (searchInfo == null || searchInfo.isValid(card)) {
list.add(card); list.add(card);
} }
} }
...@@ -178,38 +182,16 @@ public class CardLoader implements ICardSearcher { ...@@ -178,38 +182,16 @@ public class CardLoader implements ICardSearcher {
} }
@Override @Override
public void search(String prefixWord, String suffixWord, public void search(CardSearchInfo searchInfo) {
long attribute, long level, long race, String limitName = searchInfo.getLimitName();
String limitName, long limit, int limit = searchInfo.getLimitType();
String atk, String def, long pscale,
long setcode, long category, long ot, int linkKey, long... types) {
CardSearchInfo searchInfo = new CardSearchInfo();
if (!TextUtils.isEmpty(prefixWord)) {
searchInfo.keyWord1 = prefixWord;
searchInfo.keyWordSetcode1 = mStringManager.getSetCode(prefixWord);
}
if (!TextUtils.isEmpty(suffixWord)) {
searchInfo.keyWord2 = suffixWord;
searchInfo.keyWordSetcode2 = mStringManager.getSetCode(suffixWord);
}
searchInfo.attribute = (int) attribute;
searchInfo.level = (int) level;
searchInfo.atk = atk;
searchInfo.def = def;
searchInfo.ot = (int) ot;
searchInfo.linkKey = linkKey;
searchInfo.types = types;
searchInfo.category = category;
searchInfo.race = race;
searchInfo.pscale = (int) pscale;
searchInfo.setcode = setcode;
LimitList limitList = null; LimitList limitList = null;
List<Integer> inCards = null;
if (!TextUtils.isEmpty(limitName)) { if (!TextUtils.isEmpty(limitName)) {
limitList = mLimitManager.getLimit(limitName); limitList = mLimitManager.getLimit(limitName);
setLimitList(limitList); setLimitList(limitList);
LimitType cardLimitType = LimitType.valueOf(limit);
if (limitList != null) { if (limitList != null) {
LimitType cardLimitType = LimitType.valueOf(limit);
List<Integer> ids; List<Integer> ids;
if (cardLimitType == LimitType.Forbidden) { if (cardLimitType == LimitType.Forbidden) {
ids = limitList.forbidden; ids = limitList.forbidden;
...@@ -222,13 +204,11 @@ public class CardLoader implements ICardSearcher { ...@@ -222,13 +204,11 @@ public class CardLoader implements ICardSearcher {
} else { } else {
ids = null; ids = null;
} }
if (ids != null) { inCards = ids;
searchInfo.inCards = ids;
}
} }
} else { } else {
setLimitList(null); setLimitList(null);
} }
loadData(searchInfo); loadData(searchInfo, inCards);
} }
} }
...@@ -8,19 +8,158 @@ import ocgcore.data.Card; ...@@ -8,19 +8,158 @@ import ocgcore.data.Card;
import ocgcore.enums.CardOt; import ocgcore.enums.CardOt;
import ocgcore.enums.CardType; import ocgcore.enums.CardType;
class CardSearchInfo { public class CardSearchInfo implements ICardFilter{
//名字或者描述 //名字或者描述
String keyWord1, keyWord2; private CardKeyWord keyWord;
int attribute; private int attribute;
int level, ot, pscale = -1; private int level;
long race, category; private int ot;
String atk, def; private int pscale = -1;
int linkKey; private long race;
List<Integer> inCards; private long category;
long[] types; private String atk;
long setcode, keyWordSetcode1, keyWordSetcode2; private String def;
private int linkKey;
private long[] types;
private long setcode;
private int limitType;
private String limitName;
CardSearchInfo() { private CardSearchInfo() {
}
public int getLimitType() {
return limitType;
}
public String getLimitName() {
return limitName;
}
public CardKeyWord getKeyWord() {
return keyWord;
}
public int getAttribute() {
return attribute;
}
public int getLevel() {
return level;
}
public int getOt() {
return ot;
}
public int getPscale() {
return pscale;
}
public long getRace() {
return race;
}
public long getCategory() {
return category;
}
public String getAtk() {
return atk;
}
public String getDef() {
return def;
}
public int getLinkKey() {
return linkKey;
}
public long[] getTypes() {
return types;
}
public long getSetcode() {
return setcode;
}
public static class Builder {
private final CardSearchInfo searchInfo = new CardSearchInfo();
public CardSearchInfo build() {
return searchInfo;
}
public Builder limitType(int limit){
searchInfo.limitType = limit;
return this;
}
public Builder limitName(String val) {
searchInfo.limitName = val;
return this;
}
public Builder keyword(String val) {
searchInfo.keyWord = new CardKeyWord(val);
return this;
}
public Builder attribute(int val) {
searchInfo.attribute = val;
return this;
}
public Builder level(int val) {
searchInfo.level = val;
return this;
}
public Builder ot(int val) {
searchInfo.ot = val;
return this;
}
public Builder pscale(int val) {
searchInfo.pscale = val;
return this;
}
public Builder race(long val) {
searchInfo.race = val;
return this;
}
public Builder category(long val) {
searchInfo.category = val;
return this;
}
public Builder atk(String val) {
searchInfo.atk = val;
return this;
}
public Builder def(String val) {
searchInfo.def = val;
return this;
}
public Builder linkKey(int linkKey) {
searchInfo.linkKey = linkKey;
return this;
}
public Builder types(long[] types) {
searchInfo.types = types;
return this;
}
public Builder setcode(long setcode) {
searchInfo.setcode = setcode;
return this;
}
} }
public static boolean containsIgnoreCase(String src, String what) { public static boolean containsIgnoreCase(String src, String what) {
...@@ -45,32 +184,11 @@ class CardSearchInfo { ...@@ -45,32 +184,11 @@ class CardSearchInfo {
return false; return false;
} }
List<Integer> getInCards() { @Override
return inCards; public boolean isValid(Card card) {
} if(keyWord != null && !keyWord.isValid(card)){
public boolean check(Card card) {
if (inCards != null && !inCards.contains(Integer.valueOf(card.Code))) {
return false; return false;
} }
if (!TextUtils.isEmpty(keyWord1)) {
if (TextUtils.isDigitsOnly(keyWord1) && keyWord1.length() >= 5) {
//code
long code = Long.parseLong(keyWord1);
return card.Code == code || card.Alias == code;
} else if (!((card.Name != null && containsIgnoreCase(card.Name, keyWord1))
|| (card.Desc != null && containsIgnoreCase(card.Desc, keyWord1))
|| (keyWordSetcode1 > 0 && card.isSetCode(keyWordSetcode1)))) {
return false;
}
}
if (!TextUtils.isEmpty(keyWord2)) {
if (!((card.Name != null && containsIgnoreCase(card.Name, keyWord2))
|| (card.Desc != null && containsIgnoreCase(card.Desc, keyWord2))
|| (keyWordSetcode2 > 0 && card.isSetCode(keyWordSetcode2)))) {
return false;
}
}
if (attribute != 0) { if (attribute != 0) {
if (card.Attribute != attribute) { if (card.Attribute != attribute) {
return false; return false;
...@@ -113,7 +231,7 @@ class CardSearchInfo { ...@@ -113,7 +231,7 @@ class CardSearchInfo {
} }
} }
if (ot > CardOt.ALL.getId()) { if (ot > CardOt.ALL.getId()) {
if(ot == CardOt.NO_EXCLUSIVE.getId()){ if (ot == CardOt.NO_EXCLUSIVE.getId()) {
if (card.Ot == CardOt.OCG.getId() || card.Ot == CardOt.TCG.getId()) { if (card.Ot == CardOt.OCG.getId() || card.Ot == CardOt.TCG.getId()) {
return false; return false;
} }
......
package cn.garymb.ygomobile.loader;
import ocgcore.data.Card;
public interface ICardFilter {
boolean isValid(Card card);
}
...@@ -3,10 +3,7 @@ package cn.garymb.ygomobile.loader; ...@@ -3,10 +3,7 @@ package cn.garymb.ygomobile.loader;
import ocgcore.data.LimitList; import ocgcore.data.LimitList;
public interface ICardSearcher extends ICardLoader{ public interface ICardSearcher extends ICardLoader{
void search(String prefixWord, String suffixWord, void search(CardSearchInfo searchInfo);
long attribute, long level, long race,String limitName,long limit,
String atk, String def,long pscale,
long setcode, long category, long ot,int link, long... types);
void onReset(); void onReset();
void setLimitList(LimitList limit); void setLimitList(LimitList limit);
LimitList getLimitList(); LimitList getLimitList();
......
...@@ -74,6 +74,7 @@ import static cn.garymb.ygomobile.Constants.PREF_READ_EX; ...@@ -74,6 +74,7 @@ import static cn.garymb.ygomobile.Constants.PREF_READ_EX;
import static cn.garymb.ygomobile.Constants.PREF_SENSOR_REFRESH; import static cn.garymb.ygomobile.Constants.PREF_SENSOR_REFRESH;
import static cn.garymb.ygomobile.Constants.PREF_START_SERVICEDUELASSISTANT; import static cn.garymb.ygomobile.Constants.PREF_START_SERVICEDUELASSISTANT;
import static cn.garymb.ygomobile.Constants.PREF_USE_EXTRA_CARD_CARDS; import static cn.garymb.ygomobile.Constants.PREF_USE_EXTRA_CARD_CARDS;
import static cn.garymb.ygomobile.Constants.PREF_WINDOW_TOP_BOTTOM;
import static cn.garymb.ygomobile.Constants.SETTINGS_AVATAR; import static cn.garymb.ygomobile.Constants.SETTINGS_AVATAR;
import static cn.garymb.ygomobile.Constants.SETTINGS_CARD_BG; import static cn.garymb.ygomobile.Constants.SETTINGS_CARD_BG;
import static cn.garymb.ygomobile.Constants.SETTINGS_COVER; import static cn.garymb.ygomobile.Constants.SETTINGS_COVER;
...@@ -138,6 +139,7 @@ public class SettingFragment extends PreferenceFragmentPlus { ...@@ -138,6 +139,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
bind(PREF_READ_EX, mSettings.isReadExpansions()); bind(PREF_READ_EX, mSettings.isReadExpansions());
bind(PREF_DEL_EX, getString(R.string.about_delete_ex)); bind(PREF_DEL_EX, getString(R.string.about_delete_ex));
bind(PERF_TEST_REPLACE_KERNEL, "需root权限,请在开发者的指导下食用"); bind(PERF_TEST_REPLACE_KERNEL, "需root权限,请在开发者的指导下食用");
bind(PREF_WINDOW_TOP_BOTTOM, ""+mSettings.getScreenPadding());
Preference preference = findPreference(PREF_READ_EX); Preference preference = findPreference(PREF_READ_EX);
if (preference != null) { if (preference != null) {
preference.setSummary(mSettings.getExpansionsPath().getAbsolutePath()); preference.setSummary(mSettings.getExpansionsPath().getAbsolutePath());
......
...@@ -7,8 +7,11 @@ public class DensityUtils { ...@@ -7,8 +7,11 @@ public class DensityUtils {
* dp转px * dp转px
*/ */
public static int dp2px(Context ctx, float dp) { public static int dp2px(Context ctx, float dp) {
if(dp == 0){
return 0;
}
float density = ctx.getResources().getDisplayMetrics().density; float density = ctx.getResources().getDisplayMetrics().density;
int px = (int) (dp * density + 0.5f);// 4.9->5 4.4->4 int px = Math.round(dp * density);// 4.9->5 4.4->4
return px; return px;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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