Commit f7441a0c authored by Percival18's avatar Percival18

utils

parent f4624eb8
......@@ -1278,7 +1278,8 @@ void Game::DrawDeckBd() {
recti extrapos = mainGame->Resize(310, 440, 797, 460);
stringw extraDeckTypeCount = stringw(dataManager.GetSysString(1056)) + " " + stringw(deckManager.TypeCount(deckManager.current_deck.extra, TYPE_FUSION)) + " " +
stringw(dataManager.GetSysString(1073)) + " " + stringw(deckManager.TypeCount(deckManager.current_deck.extra, TYPE_XYZ)) + " " +
stringw(dataManager.GetSysString(1063)) + " " + stringw(deckManager.TypeCount(deckManager.current_deck.extra, TYPE_SYNCHRO));
stringw(dataManager.GetSysString(1063)) + " " + stringw(deckManager.TypeCount(deckManager.current_deck.extra, TYPE_SYNCHRO)) + " " +
stringw(dataManager.GetSysString(1076)) + " " + stringw(deckManager.TypeCount(deckManager.current_deck.extra, TYPE_LINK));
irr::core::dimension2d<u32> extraDeckTypeSize = textFont->getDimension(extraDeckTypeCount);
textFont->draw(extraDeckTypeCount, recti(extrapos.LowerRightCorner.X - extraDeckTypeSize.Width - 5, extrapos.UpperLeftCorner.Y,
extrapos.LowerRightCorner.X, extrapos.LowerRightCorner.Y), 0xff000000, false, true);
......
......@@ -10,6 +10,7 @@
#include "single_mode.h"
#include "materials.h"
#include "../ocgcore/field.h"
#include "utils.h"
namespace ygo {
......@@ -2014,6 +2015,22 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
case irr::EET_GUI_EVENT: {
s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType) {
case irr::gui::EGET_ELEMENT_HOVERED: {
// Set cursor to an I-Beam if hovering over an edit box
if (event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
{
utils.changeCursor(ECI_IBEAM);
}
break;
}
case irr::gui::EGET_ELEMENT_LEFT: {
// Set cursor to normal if left an edit box
if (event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
{
utils.changeCursor(ECI_NORMAL);
}
break;
}
case irr::gui::EGET_BUTTON_CLICKED: {
switch(id) {
case BUTTON_CLEAR_LOG: {
......@@ -2091,6 +2108,12 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true;
break;
}
case irr::KEY_F12: {
if (!event.KeyInput.PressedDown)
utils.takeScreenshot(mainGame->device);
return true;
break;
}
default: break;
}
break;
......
......@@ -9,6 +9,7 @@
#include "netserver.h"
#include "single_mode.h"
#include <sstream>
#include "utils.h"
#ifndef _WIN32
#include <sys/types.h>
......@@ -645,6 +646,9 @@ bool Game::Initialize() {
engineMusic = irrklang::createIrrKlangDevice();
hideChat = false;
hideChatTimer = 0;
utils.initUtils();
return true;
}
void Game::MainLoop() {
......
......@@ -7,6 +7,7 @@
#include "single_mode.h"
#include "image_manager.h"
#include "game.h"
#include "utils.h"
namespace ygo {
......@@ -515,6 +516,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->device->minimizeWindow();
break;
}
case irr::KEY_F12: {
if (!event.KeyInput.PressedDown)
utils.takeScreenshot(mainGame->device);
return true;
break;
}
default: break;
}
break;
......
#include "utils.h"
#include "game.h"
namespace ygo {
Utils utils;
void Utils::initUtils() {
//create directories if missing
#ifdef WIN32
CreateDirectoryW(L"deck", NULL);
CreateDirectoryW(L"pics", NULL);
CreateDirectoryW(L"pics/field", NULL);
CreateDirectoryW(L"replay", NULL);
CreateDirectoryW(L"screenshots", NULL);
#else
#endif
}
void Utils::takeScreenshot(irr::IrrlichtDevice* device)
{
irr::video::IVideoDriver* const driver = device->getVideoDriver();
//get image from the last rendered frame
irr::video::IImage* const image = driver->createScreenShot();
if (image) //should always be true, but you never know. ;)
{
//construct a filename, consisting of local time and file extension
irr::c8 filename[64];
snprintf(filename, 64, "screenshots/ygopro_%u.png", device->getTimer()->getRealTime());
//write screenshot to file
if (!driver->writeImageToFile(image, filename))
device->getLogger()->log(L"Failed to take screenshot.", irr::ELL_WARNING);
//Don't forget to drop image since we don't need it anymore.
image->drop();
}
}
void Utils::changeCursor(ECURSOR_ICON icon) {
gui::ICursorControl* cursor = mainGame->device->getCursorControl();
if (cursor->getActiveIcon() != icon) {
cursor->setActiveIcon(icon);
}
}
}
\ No newline at end of file
#pragma once
#ifndef UTILS_H
#define UTILS_H
#include "config.h"
namespace ygo {
class Utils {
public:
void initUtils();
void takeScreenshot(irr::IrrlichtDevice* device);
void changeCursor(ECURSOR_ICON icon);
};
extern Utils utils;
}
#endif //UTILS_H
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