Commit 1be54d6f authored by fallenstardust's avatar fallenstardust

change side chat drawing

parent d6da1e2f
...@@ -527,29 +527,28 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position ...@@ -527,29 +527,28 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position
core::ustring::const_iterator iter(utext); core::ustring::const_iterator iter(utext);
while (!iter.atEnd()) { while (!iter.atEnd()) {
uchar32_t currentChar = *iter; uchar32_t currentChar = *iter;
bool lineBreak = false;
if (currentChar == L'\r') { // Mac or Windows breaks
lineBreak = true;
if (*(iter + 1) == L'\n') // Windows line breaks.
currentChar = *(++iter);
} else if (currentChar == L'\n') { // Unix breaks
lineBreak = true;
}
if (lineBreak) {
previousChar = 0;
offset.Y += supposed_line_height; //font_metrics.ascender / 64;
offset.X = position.UpperLeftCorner.X;
if (hcenter)
offset.X += (position.getWidth() - textDimension.Width) >> 1;
++iter;
continue;
}
n = getGlyphIndexByChar(currentChar); n = getGlyphIndexByChar(currentChar);
bool visible = (Invisible.findFirst(currentChar) == -1); bool visible = (Invisible.findFirst(currentChar) == -1);
if (n > 0 && visible) { if (n > 0 && visible) {
bool lineBreak = false;
if (currentChar == L'\r') { // Mac or Windows breaks
lineBreak = true;
if (*(iter + 1) == (uchar32_t)'\n') // Windows line breaks.
currentChar = *(++iter);
} else if (currentChar == (uchar32_t)'\n') { // Unix breaks
lineBreak = true;
}
if (lineBreak) {
previousChar = 0;
offset.Y += supposed_line_height; //font_metrics.ascender / 64;
offset.X = position.UpperLeftCorner.X;
if (hcenter)
offset.X += (position.getWidth() - textDimension.Width) >> 1;
++iter;
continue;
}
// Calculate the glyph offset. // Calculate the glyph offset.
s32 offx = Glyphs[n - 1].offset.X; s32 offx = Glyphs[n - 1].offset.X;
s32 offy = (font_metrics.ascender / 64) - Glyphs[n - 1].offset.Y; s32 offy = (font_metrics.ascender / 64) - Glyphs[n - 1].offset.Y;
......
...@@ -114,6 +114,7 @@ void DeckBuilder::Terminate() { ...@@ -114,6 +114,7 @@ void DeckBuilder::Terminate() {
mainGame->btnShuffleDeck->setVisible(false); mainGame->btnShuffleDeck->setVisible(false);
mainGame->btnSortDeck->setVisible(false); mainGame->btnSortDeck->setVisible(false);
mainGame->btnClearDeck->setVisible(false); mainGame->btnClearDeck->setVisible(false);
mainGame->ResizeChatInputWindow();
mainGame->imgChat->setVisible(true); mainGame->imgChat->setVisible(true);
mainGame->imgQuickAnimation->setVisible(true); mainGame->imgQuickAnimation->setVisible(true);
mainGame->wSettings->setVisible(false); mainGame->wSettings->setVisible(false);
......
This diff is collapsed.
...@@ -215,6 +215,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -215,6 +215,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame->dInfo.isInDuel = false; mainGame->dInfo.isInDuel = false;
mainGame->dInfo.isFinished = false; mainGame->dInfo.isFinished = false;
mainGame->is_building = false; mainGame->is_building = false;
mainGame->ResizeChatInputWindow();
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
if(bot_mode) if(bot_mode)
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
...@@ -381,6 +382,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) { ...@@ -381,6 +382,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
mainGame->is_building = true; mainGame->is_building = true;
mainGame->is_siding = true; mainGame->is_siding = true;
mainGame->CloseGameWindow(); mainGame->CloseGameWindow();
mainGame->ResizeChatInputWindow();
mainGame->wChat->setVisible(false); mainGame->wChat->setVisible(false);
mainGame->imgChat->setVisible(false); mainGame->imgChat->setVisible(false);
mainGame->wDeckEdit->setVisible(false); mainGame->wDeckEdit->setVisible(false);
...@@ -500,6 +502,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) { ...@@ -500,6 +502,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
mainGame->HideElement(mainGame->wLanWindow); mainGame->HideElement(mainGame->wLanWindow);
mainGame->HideElement(mainGame->wSinglePlay); mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ShowElement(mainGame->wHostPrepare); mainGame->ShowElement(mainGame->wHostPrepare);
mainGame->ResizeChatInputWindow();
mainGame->deckBuilder.prev_category = mainGame->cbCategorySelect->getSelected(); mainGame->deckBuilder.prev_category = mainGame->cbCategorySelect->getSelected();
mainGame->deckBuilder.prev_deck = mainGame->cbDeckSelect->getSelected(); mainGame->deckBuilder.prev_deck = mainGame->cbDeckSelect->getSelected();
wchar_t cate[256]; wchar_t cate[256];
...@@ -624,6 +627,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) { ...@@ -624,6 +627,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
mainGame->btnM2->setVisible(false); mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false); mainGame->btnEP->setVisible(false);
mainGame->btnShuffle->setVisible(false); mainGame->btnShuffle->setVisible(false);
mainGame->ResizeChatInputWindow();
if(!mainGame->chkIgnore1->isChecked()) if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true); mainGame->wChat->setVisible(true);
if(mainGame->chkDefaultShowChain->isChecked()) { if(mainGame->chkDefaultShowChain->isChecked()) {
...@@ -696,6 +700,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) { ...@@ -696,6 +700,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
mainGame->btnStartBot->setEnabled(true); mainGame->btnStartBot->setEnabled(true);
mainGame->btnBotCancel->setEnabled(true); mainGame->btnBotCancel->setEnabled(true);
mainGame->stTip->setVisible(false); mainGame->stTip->setVisible(false);
mainGame->ResizeChatInputWindow();
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
if(bot_mode) if(bot_mode)
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
......
...@@ -2011,7 +2011,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -2011,7 +2011,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
mainGame->imgChat->setImage(imageManager.tShut); mainGame->imgChat->setImage(imageManager.tShut);
} }
mainGame->chkIgnore1->setChecked(mainGame->gameConf.chkIgnore1); mainGame->chkIgnore1->setChecked(mainGame->gameConf.chkIgnore1);
bool show = (!mainGame->dInfo.isStarted || mainGame->is_building) ? false : !mainGame->chkIgnore1->isChecked(); bool show = (mainGame->is_building && !mainGame->is_siding) ? false : !mainGame->chkIgnore1->isChecked();
mainGame->wChat->setVisible(show); mainGame->wChat->setVisible(show);
if(!show) if(!show)
mainGame->ClearChatMsg(); mainGame->ClearChatMsg();
......
...@@ -964,7 +964,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) { ...@@ -964,7 +964,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
btnShuffleDeck->setVisible(false); btnShuffleDeck->setVisible(false);
btnSortDeck->setVisible(false); btnSortDeck->setVisible(false);
btnClearDeck->setVisible(false); btnClearDeck->setVisible(false);
btnSideOK = env->addButton(rect<s32>(510 * xScale, 40 * yScale, 820 * xScale, 80 * yScale), 0, BUTTON_SIDE_OK, dataManager.GetSysString(1334)); btnSideOK = env->addButton(rect<s32>(400 * xScale, 40 * yScale, 710 * xScale, 80 * yScale), 0, BUTTON_SIDE_OK, dataManager.GetSysString(1334));
ChangeToIGUIImageButton(btnSideOK, imageManager.tButton_L, imageManager.tButton_L_pressed); ChangeToIGUIImageButton(btnSideOK, imageManager.tButton_L, imageManager.tButton_L_pressed);
btnSideOK->setVisible(false); btnSideOK->setVisible(false);
btnSideShuffle = env->addButton(rect<s32>(310 * xScale, 100 * yScale, 370 * xScale, 130 * yScale), 0, BUTTON_SHUFFLE_DECK, dataManager.GetSysString(1307)); btnSideShuffle = env->addButton(rect<s32>(310 * xScale, 100 * yScale, 370 * xScale, 130 * yScale), 0, BUTTON_SHUFFLE_DECK, dataManager.GetSysString(1307));
...@@ -1582,7 +1582,7 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, ...@@ -1582,7 +1582,7 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth,
strBuffer[pbuffer++] = c; strBuffer[pbuffer++] = c;
} }
strBuffer[pbuffer] = 0; strBuffer[pbuffer] = 0;
pControl->setText(strBuffer); if(pControl) pControl->setText(strBuffer);
ret.assign(strBuffer); ret.assign(strBuffer);
return ret; return ret;
} }
...@@ -1777,10 +1777,10 @@ void Game::LoadConfig() { ...@@ -1777,10 +1777,10 @@ void Game::LoadConfig() {
gameConf.gamename[0] = 0; gameConf.gamename[0] = 0;
BufferIO::DecodeUTF8(android::getLastCategory(appMain).c_str(), wstr);; BufferIO::DecodeUTF8(android::getLastCategory(appMain).c_str(), wstr);;
BufferIO::CopyWStr(wstr, gameConf.lastcategory, 64); BufferIO::CopyWStr(wstr, gameConf.lastcategory, 64);
//irr:os::Printer::log("getLastCategory", android::getLastCategory(appMain).c_str());
BufferIO::DecodeUTF8(android::getLastDeck(appMain).c_str(), wstr); BufferIO::DecodeUTF8(android::getLastDeck(appMain).c_str(), wstr);
BufferIO::CopyWStr(wstr, gameConf.lastdeck, 64); BufferIO::CopyWStr(wstr, gameConf.lastdeck, 64);
//os::Printer::log(android::getFontPath(appMain).c_str());
BufferIO::DecodeUTF8(android::getFontPath(appMain).c_str(), wstr); BufferIO::DecodeUTF8(android::getFontPath(appMain).c_str(), wstr);
BufferIO::CopyWStr(wstr, gameConf.numfont, 256); BufferIO::CopyWStr(wstr, gameConf.numfont, 256);
BufferIO::CopyWStr(wstr, gameConf.textfont, 256); BufferIO::CopyWStr(wstr, gameConf.textfont, 256);
...@@ -2128,6 +2128,7 @@ void Game::CloseDuelWindow() { ...@@ -2128,6 +2128,7 @@ void Game::CloseDuelWindow() {
lstHostList->clear(); lstHostList->clear();
DuelClient::hosts.clear(); DuelClient::hosts.clear();
ClearTextures(); ClearTextures();
ResizeChatInputWindow();
closeDoneSignal.Set(); closeDoneSignal.Set();
} }
int Game::LocalPlayer(int player) const { int Game::LocalPlayer(int player) const {
...@@ -2171,6 +2172,14 @@ int Game::ChatLocalPlayer(int player) { ...@@ -2171,6 +2172,14 @@ int Game::ChatLocalPlayer(int player) {
const wchar_t* Game::LocalName(int local_player) { const wchar_t* Game::LocalName(int local_player) {
return local_player == 0 ? dInfo.hostname : dInfo.clientname; return local_player == 0 ? dInfo.hostname : dInfo.clientname;
} }
void Game::ResizeChatInputWindow() {
s32 x = 305 * xScale;
if(is_building) x = 802 * xScale;
//305 * xScale, 610 * yScale, 1020 * xScale, 640 * yScale
wChat->setRelativePosition(recti(x, (GAME_HEIGHT - 30) * xScale, GAME_WIDTH * xScale, GAME_HEIGHT * yScale));
//3 * xScale, 2 * yScale, 710 * xScale, 28 * yScale
ebChatInput->setRelativePosition(recti(3 * xScale, 2 * yScale, (GAME_WIDTH - 6) * xScale - wChat->getRelativePosition().UpperLeftCorner.X, 28 * xScale));
}
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);
recti pos = window->getRelativePosition(); recti pos = window->getRelativePosition();
......
...@@ -210,7 +210,7 @@ public: ...@@ -210,7 +210,7 @@ public:
editbox->setText(text.c_str()); editbox->setText(text.c_str());
} }
void ResizeChatInputWindow();
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);
...@@ -262,6 +262,8 @@ public: ...@@ -262,6 +262,8 @@ public:
bool is_building; bool is_building;
bool is_siding; bool is_siding;
irr::core::dimension2d<irr::u32> window_size;
ClientField dField; ClientField dField;
DeckBuilder deckBuilder; DeckBuilder deckBuilder;
MenuHandler menuHandler; MenuHandler menuHandler;
......
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