Commit 826d0df9 authored by fallenstardust's avatar fallenstardust

update Gframe

parent 82b242e1
...@@ -11,7 +11,7 @@ namespace irr { ...@@ -11,7 +11,7 @@ namespace irr {
namespace gui { namespace gui {
void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect, void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> position, core::position2d<s32> rotationPoint, f32 rotation, core::vector2df scale, bool useAlphaChannel, video::SColor color) { core::vector2d<s32> position, core::vector2d<s32> rotationPoint, f32 rotation, core::vector2df scale, bool useAlphaChannel, video::SColor color) {
irr::video::SMaterial material; irr::video::SMaterial material;
irr::core::matrix4 oldProjMat = driver->getTransform(irr::video::ETS_PROJECTION); irr::core::matrix4 oldProjMat = driver->getTransform(irr::video::ETS_PROJECTION);
driver->setTransform(irr::video::ETS_PROJECTION, irr::core::matrix4()); driver->setTransform(irr::video::ETS_PROJECTION, irr::core::matrix4());
...@@ -70,7 +70,7 @@ void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, co ...@@ -70,7 +70,7 @@ void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, co
driver->setTransform(irr::video::ETS_VIEW, oldViewMat); driver->setTransform(irr::video::ETS_VIEW, oldViewMat);
} }
void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect, void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> corner[4], bool useAlphaChannel, video::SColor color) { core::vector2d<s32> corner[4], bool useAlphaChannel, video::SColor color) {
irr::video::SMaterial material; irr::video::SMaterial material;
irr::core::matrix4 oldProjMat = driver->getTransform(irr::video::ETS_PROJECTION); irr::core::matrix4 oldProjMat = driver->getTransform(irr::video::ETS_PROJECTION);
driver->setTransform(irr::video::ETS_PROJECTION, irr::core::matrix4()); driver->setTransform(irr::video::ETS_PROJECTION, irr::core::matrix4());
...@@ -136,8 +136,8 @@ void CGUIImageButton::draw() { ...@@ -136,8 +136,8 @@ void CGUIImageButton::draw() {
return; return;
IGUISkin* skin = Environment->getSkin(); IGUISkin* skin = Environment->getSkin();
video::IVideoDriver* driver = Environment->getVideoDriver(); video::IVideoDriver* driver = Environment->getVideoDriver();
core::position2di center = AbsoluteRect.getCenter(); core::vector2di center = AbsoluteRect.getCenter();
core::position2di pos = center; core::vector2di pos = center;
pos.X -= (s32)(ImageRect.getWidth() * imageScale.X * 0.5f); pos.X -= (s32)(ImageRect.getWidth() * imageScale.X * 0.5f);
pos.Y -= (s32)(ImageRect.getHeight() * imageScale.Y * 0.5f); pos.Y -= (s32)(ImageRect.getHeight() * imageScale.Y * 0.5f);
if(Pressed) { if(Pressed) {
...@@ -164,7 +164,7 @@ void CGUIImageButton::setImage(video::ITexture* image) ...@@ -164,7 +164,7 @@ void CGUIImageButton::setImage(video::ITexture* image)
Image = image; Image = image;
if(image) { if(image) {
ImageRect = core::rect<s32>(core::position2d<s32>(0, 0), image->getOriginalSize()); ImageRect = core::rect<s32>(core::vector2d<s32>(0, 0), image->getOriginalSize());
if(isFixedSize) if(isFixedSize)
imageScale = core::vector2df((irr::f32)imageSize.Width / image->getSize().Width, (irr::f32)imageSize.Height / image->getSize().Height); imageScale = core::vector2df((irr::f32)imageSize.Width / image->getSize().Width, (irr::f32)imageSize.Height / image->getSize().Height);
} }
......
...@@ -8,10 +8,10 @@ namespace irr { ...@@ -8,10 +8,10 @@ namespace irr {
namespace gui { namespace gui {
void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect, void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> position, core::position2d<s32> rotationPoint, f32 rotation = 0.0f, core::vector2d<s32> position, core::vector2d<s32> rotationPoint, f32 rotation = 0.0f,
core::vector2df scale = core::vector2df(1.0, 1.0), bool useAlphaChannel = true, video::SColor color = 0xffffffff); core::vector2df scale = core::vector2df(1.0, 1.0), bool useAlphaChannel = true, video::SColor color = 0xffffffff);
void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect, void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> corner[4], bool useAlphaChannel = true, video::SColor color = 0xffffffff); core::vector2d<s32> corner[4], bool useAlphaChannel = true, video::SColor color = 0xffffffff);
class CGUIImageButton : public CGUIButton { class CGUIImageButton : public CGUIButton {
public: public:
CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle); CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle);
......
...@@ -505,7 +505,7 @@ void CGUITTFont::drawUstring(const core::ustring& utext, const core::rect<s32>&p ...@@ -505,7 +505,7 @@ void CGUITTFont::drawUstring(const core::ustring& utext, const core::rect<s32>&p
// Set up some variables. // Set up some variables.
core::dimension2d<s32> textDimension; core::dimension2d<s32> textDimension;
core::position2d<s32> offset = position.UpperLeftCorner; core::vector2d<s32> offset = position.UpperLeftCorner;
// Determine offset positions. // Determine offset positions.
if (hcenter || vcenter) { if (hcenter || vcenter) {
...@@ -561,7 +561,7 @@ void CGUITTFont::drawUstring(const core::ustring& utext, const core::rect<s32>&p ...@@ -561,7 +561,7 @@ void CGUITTFont::drawUstring(const core::ustring& utext, const core::rect<s32>&p
// Determine rendering information. // Determine rendering information.
SGUITTGlyph& glyph = Glyphs[n - 1]; SGUITTGlyph& glyph = Glyphs[n - 1];
CGUITTGlyphPage* const page = Glyph_Pages[glyph.glyph_page]; CGUITTGlyphPage* const page = Glyph_Pages[glyph.glyph_page];
page->render_positions.push_back(core::position2di(offset.X + offx, offset.Y + offy)); page->render_positions.push_back(core::vector2di(offset.X + offx, offset.Y + offy));
page->render_source_rects.push_back(glyph.source_rect); page->render_source_rects.push_back(glyph.source_rect);
Render_Map.set(glyph.glyph_page, page); Render_Map.set(glyph.glyph_page, page);
} }
...@@ -832,7 +832,7 @@ video::IImage* CGUITTFont::createTextureFromChar(const uchar32_t& ch) { ...@@ -832,7 +832,7 @@ video::IImage* CGUITTFont::createTextureFromChar(const uchar32_t& ch) {
// Copy the image data out of the page texture. // Copy the image data out of the page texture.
core::dimension2du glyph_size(glyph.source_rect.getSize()); core::dimension2du glyph_size(glyph.source_rect.getSize());
video::IImage* image = Driver->createImage(format, glyph_size); video::IImage* image = Driver->createImage(format, glyph_size);
pageholder->copyTo(image, core::position2di(0, 0), glyph.source_rect); pageholder->copyTo(image, core::vector2di(0, 0), glyph.source_rect);
tex->unlock(); tex->unlock();
return image; return image;
......
...@@ -422,7 +422,9 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl ...@@ -422,7 +422,9 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl
return scriptBuffer; return scriptBuffer;
} }
unsigned char* DataManager::ReadScriptFromFile(const char* script_name, int* slen) { unsigned char* DataManager::ReadScriptFromFile(const char* script_name, int* slen) {
FILE* fp = std::fopen(script_name, "rb"); wchar_t fname[256]{};
BufferIO::DecodeUTF8(script_name, fname);
FILE* fp = mywfopen(fname, "rb");
if (!fp) if (!fp)
return nullptr; return nullptr;
size_t len = std::fread(scriptBuffer, 1, sizeof scriptBuffer, fp); size_t len = std::fread(scriptBuffer, 1, sizeof scriptBuffer, fp);
......
...@@ -136,14 +136,14 @@ void DeckBuilder::Terminate() { ...@@ -136,14 +136,14 @@ void DeckBuilder::Terminate() {
mainGame->scrPackCards->setPos(0); mainGame->scrPackCards->setPos(0);
int catesel = mainGame->cbDBCategory->getSelected(); int catesel = mainGame->cbDBCategory->getSelected();
char linebuf[256]; char linebuf[256];
if(catesel >= 0) if (catesel >= 0)
BufferIO::CopyWStr(mainGame->cbDBCategory->getItem(catesel), mainGame->gameConf.lastcategory, 64); BufferIO::CopyWideString(mainGame->cbDBCategory->getItem(catesel), mainGame->gameConf.lastcategory);
BufferIO::EncodeUTF8(mainGame->gameConf.lastcategory, linebuf); BufferIO::EncodeUTF8(mainGame->gameConf.lastcategory, linebuf);
android::setLastCategory(mainGame->appMain, linebuf); android::setLastCategory(mainGame->appMain, linebuf);
//irr:os::Printer::log("setLastCategory", linebuf); //irr:os::Printer::log("setLastCategory", linebuf);
int decksel = mainGame->cbDBDecks->getSelected(); int decksel = mainGame->cbDBDecks->getSelected();
if(decksel >= 0) if (decksel >= 0)
BufferIO::CopyWStr(mainGame->cbDBDecks->getItem(decksel), mainGame->gameConf.lastdeck, 64); BufferIO::CopyWideString(mainGame->cbDBDecks->getItem(decksel), mainGame->gameConf.lastdeck);
BufferIO::EncodeUTF8(mainGame->gameConf.lastdeck, linebuf); BufferIO::EncodeUTF8(mainGame->gameConf.lastdeck, linebuf);
android::setLastDeck(mainGame->appMain, linebuf); android::setLastDeck(mainGame->appMain, linebuf);
//os::Printer::log("setLastDeck", linebuf); //os::Printer::log("setLastDeck", linebuf);
......
#ifndef DECK_CON_H #ifndef DECK_CON_H
#define DECK_CON_H #define DECK_CON_H
#include "config.h"
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <irrlicht.h>
#include "data_manager.h" #include "data_manager.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
...@@ -57,7 +57,7 @@ public: ...@@ -57,7 +57,7 @@ public:
unsigned int filter_scl{}; unsigned int filter_scl{};
unsigned int filter_marks{}; unsigned int filter_marks{};
int filter_lm{}; int filter_lm{};
position2di mouse_pos; irr::core::vector2di mouse_pos;
int hovered_code{}; int hovered_code{};
int hovered_pos{}; int hovered_pos{};
int hovered_seq{ -1 }; int hovered_seq{ -1 };
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
code_pointer draging_pointer; code_pointer draging_pointer;
int prev_category{}; int prev_category{};
int prev_deck{}; int prev_deck{};
s32 prev_operation{}; irr::s32 prev_operation{};
int prev_sel{ -1 }; int prev_sel{ -1 };
bool is_modified{}; bool is_modified{};
bool readonly{}; bool readonly{};
......
...@@ -43,6 +43,7 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, ...@@ -43,6 +43,7 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width,
driver->draw3DLine(vec[3].Pos, vec[2].Pos); driver->draw3DLine(vec[3].Pos, vec[2].Pos);
driver->draw3DLine(vec[2].Pos, vec[0].Pos); driver->draw3DLine(vec[2].Pos, vec[0].Pos);
} }
} }
void Game::DrawSelectionLine(irr::gui::IGUIElement* element, int width, irr::video::SColor color) { void Game::DrawSelectionLine(irr::gui::IGUIElement* element, int width, irr::video::SColor color) {
recti pos = element->getAbsolutePosition(); recti pos = element->getAbsolutePosition();
...@@ -896,12 +897,12 @@ void Game::DrawSpec() { ...@@ -896,12 +897,12 @@ void Game::DrawSpec() {
break; break;
} }
case 7: {//show normal summoning case 7: {//show normal summoning
core::position2d<s32> corner[4]; irr::core::vector2d<s32> corner[4];
float y = sin(showcarddif * 3.1415926f / 180.0f) * CARD_IMG_HEIGHT * mainGame->yScale; float y = sin(showcarddif * 3.1415926f / 180.0f) * CARD_IMG_HEIGHT * mainGame->yScale;
corner[0] = core::position2d<s32>(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale - (CARD_IMG_HEIGHT * mainGame->yScale - y) * 0.3f , 404 * mainGame->yScale - y); corner[0] = irr::core::vector2d<s32>(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale - (CARD_IMG_HEIGHT * mainGame->yScale - y) * 0.3f , 404 * mainGame->yScale - y);
corner[1] = core::position2d<s32>(660 * xScale + (CARD_IMG_WIDTH / 2) * yScale + (CARD_IMG_HEIGHT * mainGame->yScale - y) * 0.3f , 404 * mainGame->yScale - y); corner[1] = irr::core::vector2d<s32>(660 * xScale + (CARD_IMG_WIDTH / 2) * yScale + (CARD_IMG_HEIGHT * mainGame->yScale - y) * 0.3f , 404 * mainGame->yScale - y);
corner[2] = core::position2d<s32>(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale, 404 * mainGame->yScale); corner[2] = irr::core::vector2d<s32>(660 * xScale - (CARD_IMG_WIDTH / 2) * yScale, 404 * mainGame->yScale);
corner[3] = core::position2d<s32>(660 * xScale + (CARD_IMG_WIDTH / 2) * yScale, 404 * mainGame->yScale); corner[3] = irr::core::vector2d<s32>(660 * xScale + (CARD_IMG_WIDTH / 2) * yScale, 404 * mainGame->yScale);
irr::gui::Draw2DImageQuad(driver, showimg, rect<s32>(0, 0, orisize.Width, orisize.Height), corner); irr::gui::Draw2DImageQuad(driver, showimg, rect<s32>(0, 0, orisize.Width, orisize.Height), corner);
showcardp++; showcardp++;
showcarddif += 9; showcarddif += 9;
...@@ -1039,7 +1040,7 @@ void Game::DrawSpec() { ...@@ -1039,7 +1040,7 @@ void Game::DrawSpec() {
recti rectloc(x, y - chatRectY - h, x + 2 + w, y - chatRectY); recti rectloc(x, y - chatRectY - h, x + 2 + w, y - chatRectY);
recti msgloc(x, y - chatRectY - h, x - 4, y - chatRectY); recti msgloc(x, y - chatRectY - h, x - 4, y - chatRectY);
recti shadowloc = msgloc + position2di(1, 1); recti shadowloc = msgloc + irr::core::vector2di(1, 1);
driver->draw2DRectangle(rectloc, 0xa0000000, 0xa0000000, 0xa0000000, 0xa0000000); driver->draw2DRectangle(rectloc, 0xa0000000, 0xa0000000, 0xa0000000, 0xa0000000);
guiFont->drawUstring(msg, msgloc, 0xff000000, false, false); guiFont->drawUstring(msg, msgloc, 0xff000000, false, false);
...@@ -1060,7 +1061,7 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) { ...@@ -1060,7 +1061,7 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) {
for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit) for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit)
if(win == fit->guiFading && win != wOptions && win != wANNumber) // the size of wOptions is always setted by ClientField::ShowSelectOption before showing it if(win == fit->guiFading && win != wOptions && win != wANNumber) // the size of wOptions is always setted by ClientField::ShowSelectOption before showing it
fu.fadingSize = fit->fadingSize; fu.fadingSize = fit->fadingSize;
irr::core::position2di center = fu.fadingSize.getCenter(); irr::core::vector2di center = fu.fadingSize.getCenter();
fu.fadingDiff.X = fu.fadingSize.getWidth() / 10; fu.fadingDiff.X = fu.fadingSize.getWidth() / 10;
fu.fadingDiff.Y = (fu.fadingSize.getHeight() - 4) / 10; fu.fadingDiff.Y = (fu.fadingSize.getHeight() - 4) / 10;
fu.fadingUL = center; fu.fadingUL = center;
...@@ -1145,7 +1146,7 @@ void Game::WaitFrameSignal(int frame) { ...@@ -1145,7 +1146,7 @@ void Game::WaitFrameSignal(int frame) {
signalFrame = (gameConf.quick_animation && frame >= 12) ? 12 : frame; signalFrame = (gameConf.quick_animation && frame >= 12) ? 12 : frame;
frameSignal.Wait(); frameSignal.Wait();
} }
void Game::DrawThumb(code_pointer cp, position2di pos, const std::unordered_map<int,int>* lflist, bool drag) { void Game::DrawThumb(code_pointer cp, irr::core::vector2di pos, const std::unordered_map<int,int>* lflist, bool drag) {
int code = cp->first; int code = cp->first;
int lcode = cp->second.alias; int lcode = cp->second.alias;
if(lcode == 0) if(lcode == 0)
...@@ -1249,7 +1250,7 @@ void Game::DrawDeckBd() { ...@@ -1249,7 +1250,7 @@ void Game::DrawDeckBd() {
int j = i + padding; int j = i + padding;
DrawThumb(deckManager.current_deck.main[j], Resize(314 + (i % lx) * dx, 164 + (i / lx) * dy), deckBuilder.filterList); DrawThumb(deckManager.current_deck.main[j], Resize(314 + (i % lx) * dx, 164 + (i / lx) * dy), deckBuilder.filterList);
if(deckBuilder.hovered_pos == 1 && deckBuilder.hovered_seq == j) if(deckBuilder.hovered_pos == 1 && deckBuilder.hovered_seq == j)
driver->draw2DRectangleOutline(recti ((313 + (i % lx) * dx) * xScale + CARD_THUMB_WIDTH * (mainGame->xScale - mainGame->yScale) / 2, (163 + (i / lx) * dy) * yScale, (313 + (i % lx) * dx + 1) * xScale + CARD_THUMB_WIDTH * (mainGame->xScale + mainGame->yScale) / 2, (163 + (i / lx) * dy + CARD_THUMB_HEIGHT + 1) * yScale)); driver->draw2DRectangleOutline(recti((313 + (i % lx) * dx) * xScale + CARD_THUMB_WIDTH * (mainGame->xScale - mainGame->yScale) / 2, (163 + (i / lx) * dy) * yScale, (313 + (i % lx) * dx + 1) * xScale + CARD_THUMB_WIDTH * (mainGame->xScale + mainGame->yScale) / 2, (163 + (i / lx) * dy + CARD_THUMB_HEIGHT + 1) * yScale));
} }
if(!deckBuilder.showing_pack) { if(!deckBuilder.showing_pack) {
//extra deck //extra deck
...@@ -1377,7 +1378,7 @@ void Game::DrawDeckBd() { ...@@ -1377,7 +1378,7 @@ void Game::DrawDeckBd() {
} }
} }
if(deckBuilder.is_draging) { if(deckBuilder.is_draging) {
DrawThumb(deckBuilder.draging_pointer,position2di(deckBuilder.dragx - CARD_THUMB_WIDTH / 2, deckBuilder.dragy - CARD_THUMB_HEIGHT / 2),deckBuilder.filterList, true); DrawThumb(deckBuilder.draging_pointer, irr::core::vector2di(deckBuilder.dragx - CARD_THUMB_WIDTH / 2 * mainGame->xScale, deckBuilder.dragy - CARD_THUMB_HEIGHT / 2 * mainGame->yScale), deckBuilder.filterList, true);
} }
} }
} }
...@@ -1158,7 +1158,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1158,7 +1158,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
s32 x = event.MouseInput.X; s32 x = event.MouseInput.X;
s32 y = event.MouseInput.Y; s32 y = event.MouseInput.Y;
hovered_location = 0; hovered_location = 0;
irr::core::position2di pos(x, y); irr::core::vector2di pos(x, y);
if(x < 300 * mainGame->xScale) if(x < 300 * mainGame->xScale)
break; break;
if(mainGame->gameConf.control_mode == 1) { if(mainGame->gameConf.control_mode == 1) {
...@@ -1580,7 +1580,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1580,7 +1580,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
bool should_show_tip = false; bool should_show_tip = false;
s32 x = event.MouseInput.X; s32 x = event.MouseInput.X;
s32 y = event.MouseInput.Y; s32 y = event.MouseInput.Y;
irr::core::position2di pos(x, y); irr::core::vector2di pos(x, y);
wchar_t formatBuffer[2048]; wchar_t formatBuffer[2048];
if(x < 300) { if(x < 300) {
irr::gui::IGUIElement* root = mainGame->env->getRootGUIElement(); irr::gui::IGUIElement* root = mainGame->env->getRootGUIElement();
...@@ -1621,9 +1621,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1621,9 +1621,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(deck[hovered_controler].size()) if(deck[hovered_controler].size())
mcard = deck[hovered_controler].back(); mcard = deck[hovered_controler].back();
} else { } else {
if(irr::core::recti(327 * mainGame->xScale, 8 * mainGame->yScale, 630 * mainGame->xScale, 72 * mainGame->yScale).isPointInside(pos)) if(mainGame->Resize(327, 8, 630, 72).isPointInside(pos))
mplayer = 0; mplayer = 0;
else if(irr::core::recti(689 * mainGame->xScale, 8 * mainGame->yScale, 991 * mainGame->xScale, 72 * mainGame->yScale).isPointInside(pos)) else if(mainGame->Resize(689, 8, 991, 72).isPointInside(pos))
mplayer = 1; mplayer = 1;
} }
} }
...@@ -1635,7 +1635,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1635,7 +1635,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(mainGame->stTip->isVisible()) { if(mainGame->stTip->isVisible()) {
should_show_tip = true; should_show_tip = true;
irr::core::recti tpos = mainGame->stTip->getRelativePosition(); irr::core::recti tpos = mainGame->stTip->getRelativePosition();
mainGame->stTip->setRelativePosition(irr::core::position2di(x - tpos.getWidth() - 10 * mainGame->xScale, mcard ? y - tpos.getHeight() - (10 * mainGame->yScale) : y + 10 * mainGame->xScale)); mainGame->stTip->setRelativePosition(irr::core::vector2di(x - tpos.getWidth() - 10 * mainGame->xScale, mcard ? y - tpos.getHeight() - (10 * mainGame->yScale) : y + 10 * mainGame->xScale));
} }
} }
if(mcard != hovered_card) { if(mcard != hovered_card) {
...@@ -2196,7 +2196,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -2196,7 +2196,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
} }
case irr::EET_MOUSE_INPUT_EVENT: { case irr::EET_MOUSE_INPUT_EVENT: {
IGUIElement* root = mainGame->env->getRootGUIElement(); IGUIElement* root = mainGame->env->getRootGUIElement();
position2di mousepos = position2di(event.MouseInput.X, event.MouseInput.Y); irr::core::vector2di mousepos = irr::core::vector2di(event.MouseInput.X, event.MouseInput.Y);
irr::gui::IGUIElement* eventElement = root->getElementFromPoint(mousepos); irr::gui::IGUIElement* eventElement = root->getElementFromPoint(mousepos);
u32 static presstime, leftuptime; u32 static presstime, leftuptime;
switch(event.MouseInput.Event) { switch(event.MouseInput.Event) {
...@@ -2402,7 +2402,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -2402,7 +2402,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
void ClientField::GetHoverField(int x, int y) { void ClientField::GetHoverField(int x, int y) {
irr::core::recti sfRect(430 * mainGame->xScale, 504 * mainGame->yScale, 875 * mainGame->xScale, 600 * mainGame->yScale); irr::core::recti sfRect(430 * mainGame->xScale, 504 * mainGame->yScale, 875 * mainGame->xScale, 600 * mainGame->yScale);
irr::core::recti ofRect(531 * mainGame->xScale, 135 * mainGame->yScale, 800 * mainGame->xScale, 191 * mainGame->yScale); irr::core::recti ofRect(531 * mainGame->xScale, 135 * mainGame->yScale, 800 * mainGame->xScale, 191 * mainGame->yScale);
irr::core::position2di pos(x, y); irr::core::vector2di pos(x, y);
int rule = (mainGame->dInfo.duel_rule >= 4) ? 1 : 0; int rule = (mainGame->dInfo.duel_rule >= 4) ? 1 : 0;
if(sfRect.isPointInside(pos)) { if(sfRect.isPointInside(pos)) {
int hc = hand[0].size(); int hc = hand[0].size();
...@@ -2635,31 +2635,31 @@ void ClientField::ShowMenu(int flag, int x, int y) { ...@@ -2635,31 +2635,31 @@ void ClientField::ShowMenu(int flag, int x, int y) {
return; return;
} }
menu_card = clicked_card; menu_card = clicked_card;
int height = 0; int height = 1;
if(flag & COMMAND_ACTIVATE) { if(flag & COMMAND_ACTIVATE) {
mainGame->btnActivate->setVisible(true); mainGame->btnActivate->setVisible(true);
mainGame->btnActivate->setRelativePosition(position2di(0, height)); mainGame->btnActivate->setRelativePosition(irr::core::vector2di(1, height));
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
height += 60 * mainGame->yScale; height += 60 * mainGame->yScale;
#endif #endif
} else mainGame->btnActivate->setVisible(false); } else mainGame->btnActivate->setVisible(false);
if(flag & COMMAND_SUMMON) { if(flag & COMMAND_SUMMON) {
mainGame->btnSummon->setVisible(true); mainGame->btnSummon->setVisible(true);
mainGame->btnSummon->setRelativePosition(position2di(0, height)); mainGame->btnSummon->setRelativePosition(irr::core::vector2di(1, height));
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
height += 60 * mainGame->yScale; height += 60 * mainGame->yScale;
#endif #endif
} else mainGame->btnSummon->setVisible(false); } else mainGame->btnSummon->setVisible(false);
if(flag & COMMAND_SPSUMMON) { if(flag & COMMAND_SPSUMMON) {
mainGame->btnSPSummon->setVisible(true); mainGame->btnSPSummon->setVisible(true);
mainGame->btnSPSummon->setRelativePosition(position2di(0, height)); mainGame->btnSPSummon->setRelativePosition(irr::core::vector2di(1, height));
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
height += 60 * mainGame->yScale; height += 60 * mainGame->yScale;
#endif #endif
} else mainGame->btnSPSummon->setVisible(false); } else mainGame->btnSPSummon->setVisible(false);
if(flag & COMMAND_MSET) { if(flag & COMMAND_MSET) {
mainGame->btnMSet->setVisible(true); mainGame->btnMSet->setVisible(true);
mainGame->btnMSet->setRelativePosition(position2di(0, height)); mainGame->btnMSet->setRelativePosition(irr::core::vector2di(1, height));
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
height += 60 * mainGame->yScale; height += 60 * mainGame->yScale;
#endif #endif
...@@ -2670,7 +2670,7 @@ void ClientField::ShowMenu(int flag, int x, int y) { ...@@ -2670,7 +2670,7 @@ void ClientField::ShowMenu(int flag, int x, int y) {
else else
mainGame->btnSSet->setText(dataManager.GetSysString(1159)); mainGame->btnSSet->setText(dataManager.GetSysString(1159));
mainGame->btnSSet->setVisible(true); mainGame->btnSSet->setVisible(true);
mainGame->btnSSet->setRelativePosition(position2di(0, height)); mainGame->btnSSet->setRelativePosition(irr::core::vector2di(1, height));
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
height += 60 * mainGame->yScale; height += 60 * mainGame->yScale;
#endif #endif
...@@ -2683,35 +2683,35 @@ void ClientField::ShowMenu(int flag, int x, int y) { ...@@ -2683,35 +2683,35 @@ void ClientField::ShowMenu(int flag, int x, int y) {
else else
mainGame->btnRepos->setText(dataManager.GetSysString(1156)); mainGame->btnRepos->setText(dataManager.GetSysString(1156));
mainGame->btnRepos->setVisible(true); mainGame->btnRepos->setVisible(true);
mainGame->btnRepos->setRelativePosition(position2di(0, height)); mainGame->btnRepos->setRelativePosition(irr::core::vector2di(1, height));
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
height += 60 * mainGame->yScale; height += 60 * mainGame->yScale;
#endif #endif
} else mainGame->btnRepos->setVisible(false); } else mainGame->btnRepos->setVisible(false);
if(flag & COMMAND_ATTACK) { if(flag & COMMAND_ATTACK) {
mainGame->btnAttack->setVisible(true); mainGame->btnAttack->setVisible(true);
mainGame->btnAttack->setRelativePosition(position2di(0, height)); mainGame->btnAttack->setRelativePosition(irr::core::vector2di(1, height));
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
height += 60 * mainGame->yScale; height += 60 * mainGame->yScale;
#endif #endif
} else mainGame->btnAttack->setVisible(false); } else mainGame->btnAttack->setVisible(false);
if(flag & COMMAND_LIST) { if(flag & COMMAND_LIST) {
mainGame->btnShowList->setVisible(true); mainGame->btnShowList->setVisible(true);
mainGame->btnShowList->setRelativePosition(position2di(0, height)); mainGame->btnShowList->setRelativePosition(irr::core::vector2di(1, height));
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
height += 60 * mainGame->yScale; height += 60 * mainGame->yScale;
#endif #endif
} else mainGame->btnShowList->setVisible(false); } else mainGame->btnShowList->setVisible(false);
if(flag & COMMAND_OPERATION) { if(flag & COMMAND_OPERATION) {
mainGame->btnOperation->setVisible(true); mainGame->btnOperation->setVisible(true);
mainGame->btnOperation->setRelativePosition(position2di(0, height)); mainGame->btnOperation->setRelativePosition(irr::core::vector2di(1, height));
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
height += 60 * mainGame->yScale; height += 60 * mainGame->yScale;
#endif #endif
} else mainGame->btnOperation->setVisible(false); } else mainGame->btnOperation->setVisible(false);
if(flag & COMMAND_RESET) { if(flag & COMMAND_RESET) {
mainGame->btnReset->setVisible(true); mainGame->btnReset->setVisible(true);
mainGame->btnReset->setRelativePosition(position2di(0, height)); mainGame->btnReset->setRelativePosition(irr::core::vector2di(1, height));
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
height += 60 * mainGame->yScale; height += 60 * mainGame->yScale;
#endif #endif
......
...@@ -133,6 +133,15 @@ void Game::onHandleAndroidCommand(ANDROID_APP app, int32_t cmd){ ...@@ -133,6 +133,15 @@ void Game::onHandleAndroidCommand(ANDROID_APP app, int32_t cmd){
break; break;
} }
} }
bool IsExtension(const char* filename, const char* extension) {
auto flen = std::strlen(filename);
auto elen = std::strlen(extension);
if (!elen || flen < elen)
return false;
return !mystrncasecmp(filename + (flen - elen), extension, elen);
}
bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) { bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
this->appMain = app; this->appMain = app;
srand(time(0)); srand(time(0));
...@@ -157,7 +166,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) { ...@@ -157,7 +166,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
if (!android::perfromTrick(app)) { if (!android::perfromTrick(app)) {
return false; return false;
} }
core::position2di appPosition = android::initJavaBridge(app, device); irr::core::vector2di appPosition = android::initJavaBridge(app, device);
setPositionFix(appPosition); setPositionFix(appPosition);
device->setProcessReceiver(this); device->setProcessReceiver(this);
...@@ -2216,15 +2225,15 @@ recti Game::Resize(s32 x, s32 y, s32 x2, s32 y2, s32 dx, s32 dy, s32 dx2, s32 dy ...@@ -2216,15 +2225,15 @@ recti Game::Resize(s32 x, s32 y, s32 x2, s32 y2, s32 dx, s32 dy, s32 dx2, s32 dy
y2 = y2 * yScale + dy2; y2 = y2 * yScale + dy2;
return recti(x, y, x2, y2); return recti(x, y, x2, y2);
} }
position2di Game::Resize(s32 x, s32 y) { irr::core::vector2di Game::Resize(s32 x, s32 y) {
x = x * xScale; x = x * xScale;
y = y * yScale; y = y * yScale;
return position2di(x, y); return irr::core::vector2di(x, y);
} }
position2di Game::ResizeReverse(s32 x, s32 y) { irr::core::vector2di Game::ResizeReverse(s32 x, s32 y) {
x = x / xScale; x = x / xScale;
y = y / yScale; y = y / yScale;
return position2di(x, y); return irr::core::vector2di(x, y);
} }
recti Game::ResizeWin(s32 x, s32 y, s32 x2, s32 y2) { recti Game::ResizeWin(s32 x, s32 y, s32 x2, s32 y2) {
s32 w = x2 - x; s32 w = x2 - x;
...@@ -2247,12 +2256,12 @@ recti Game::Resize_Y(s32 x, s32 y, s32 x2, s32 y2) { ...@@ -2247,12 +2256,12 @@ recti Game::Resize_Y(s32 x, s32 y, s32 x2, s32 y2) {
y = y * yScale; y = y * yScale;
x2 = x2 * yScale; x2 = x2 * yScale;
y2 = y2 * yScale; y2 = y2 * yScale;
return recti(x, y, x2, y2); return recti(x, y, x2, y2);
} }
position2di Game::Resize_Y(s32 x, s32 y) { irr::core::vector2di Game::Resize_Y(s32 x, s32 y) {
x = x * yScale; x = x * yScale;
y = y * yScale; y = y * yScale;
return position2di(x, y); return irr::core::vector2di(x, y);
} }
void Game::ChangeToIGUIImageWindow(irr::gui::IGUIWindow* window, irr::gui::IGUIImage** pWindowBackground, irr::video::ITexture* image) { void Game::ChangeToIGUIImageWindow(irr::gui::IGUIWindow* window, irr::gui::IGUIImage** pWindowBackground, irr::video::ITexture* image) {
window->setDrawBackground(false); window->setDrawBackground(false);
......
...@@ -28,6 +28,7 @@ constexpr int TEXT_LINE_SIZE = 256; ...@@ -28,6 +28,7 @@ constexpr int TEXT_LINE_SIZE = 256;
namespace ygo { namespace ygo {
bool IsExtension(const wchar_t* filename, const wchar_t* extension); bool IsExtension(const wchar_t* filename, const wchar_t* extension);
bool IsExtension(const char* filename, const char* extension);
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
#define LOG_TAG "ygo-jni" #define LOG_TAG "ygo-jni"
...@@ -189,7 +190,7 @@ public: ...@@ -189,7 +190,7 @@ public:
void HideElement(irr::gui::IGUIElement* element, bool set_action = false); void HideElement(irr::gui::IGUIElement* element, bool set_action = false);
void PopupElement(irr::gui::IGUIElement* element, int hideframe = 0); void PopupElement(irr::gui::IGUIElement* element, int hideframe = 0);
void WaitFrameSignal(int frame); void WaitFrameSignal(int frame);
void DrawThumb(code_pointer cp, position2di pos, const std::unordered_map<int,int>* lflist, bool drag = false); void DrawThumb(code_pointer cp, irr::core::vector2di pos, const std::unordered_map<int,int>* lflist, bool drag = false);
void DrawDeckBd(); void DrawDeckBd();
void LoadConfig(); void LoadConfig();
void SaveConfig(); void SaveConfig();
...@@ -229,12 +230,12 @@ public: ...@@ -229,12 +230,12 @@ public:
void ResizeChatInputWindow(); void ResizeChatInputWindow();
recti Resize(s32 x, s32 y, s32 x2, s32 y2); recti Resize(s32 x, s32 y, s32 x2, s32 y2);
recti Resize(s32 x, s32 y, s32 x2, s32 y2, s32 dx, s32 dy, s32 dx2, s32 dy2); recti Resize(s32 x, s32 y, s32 x2, s32 y2, s32 dx, s32 dy, s32 dx2, s32 dy2);
position2di Resize(s32 x, s32 y); irr::core::vector2di Resize(s32 x, s32 y);
position2di ResizeReverse(s32 x, s32 y); irr::core::vector2di ResizeReverse(s32 x, s32 y);
recti ResizePhaseHint(s32 x, s32 y, s32 x2, s32 y2, s32 width); recti ResizePhaseHint(s32 x, s32 y, s32 x2, s32 y2, s32 width);
recti ResizeWin(s32 x, s32 y, s32 x2, s32 y2); recti ResizeWin(s32 x, s32 y, s32 x2, s32 y2);
recti Resize_Y(s32 x, s32 y, s32 x2, s32 y2); recti Resize_Y(s32 x, s32 y, s32 x2, s32 y2);
position2di Resize_Y(s32 x, s32 y); irr::core::vector2di Resize_Y(s32 x, s32 y);
template<typename T> template<typename T>
static std::vector<T> TokenizeString(T input, const T& token); static std::vector<T> TokenizeString(T input, const T& token);
template<typename T> template<typename T>
......
#ifndef MENU_HANDLER_H #ifndef MENU_HANDLER_H
#define MENU_HANDLER_H #define MENU_HANDLER_H
#include "config.h" #include <irrlicht.h>
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
#include <android/TouchEventTransferAndroid.h> #include <android/TouchEventTransferAndroid.h>
#endif #endif
...@@ -11,8 +11,8 @@ namespace ygo { ...@@ -11,8 +11,8 @@ namespace ygo {
class MenuHandler: public irr::IEventReceiver { class MenuHandler: public irr::IEventReceiver {
public: public:
bool OnEvent(const irr::SEvent& event) override; bool OnEvent(const irr::SEvent& event) override;
s32 prev_operation; irr::s32 prev_operation{ 0 };
int prev_sel; int prev_sel{ -1 };
}; };
......
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