2013-09-01 14:27:21 +00:00
|
|
|
/*
|
2013-10-09 10:30:33 +00:00
|
|
|
** sharedstate.cpp
|
2013-09-01 14:27:21 +00:00
|
|
|
**
|
|
|
|
** This file is part of mkxp.
|
|
|
|
**
|
|
|
|
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
|
|
|
**
|
|
|
|
** mkxp is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 2 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** mkxp is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
#include "sharedstate.h"
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
#include "filesystem.h"
|
|
|
|
#include "graphics.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "audio.h"
|
|
|
|
#include "glstate.h"
|
|
|
|
#include "shader.h"
|
|
|
|
#include "texpool.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "eventthread.h"
|
|
|
|
#include "gl-util.h"
|
|
|
|
#include "global-ibo.h"
|
2013-09-04 17:07:28 +00:00
|
|
|
#include "quad.h"
|
2013-09-01 14:27:21 +00:00
|
|
|
#include "binding.h"
|
2013-12-30 00:26:39 +00:00
|
|
|
#include "exception.h"
|
2014-07-31 01:32:07 +00:00
|
|
|
#include "sharedmidistate.h"
|
|
|
|
|
2013-09-01 14:27:21 +00:00
|
|
|
#include <unistd.h>
|
2013-12-11 19:46:54 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string>
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
SharedState *SharedState::instance = 0;
|
2014-08-28 21:11:10 +00:00
|
|
|
int SharedState::rgssVersion = 0;
|
2014-07-13 12:03:18 +00:00
|
|
|
static GlobalIBO *_globalIBO = 0;
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2014-08-28 21:11:10 +00:00
|
|
|
static const char *defGameArchive()
|
|
|
|
{
|
|
|
|
if (rgssVer == 1)
|
|
|
|
return "Game.rgssad";
|
|
|
|
else if (rgssVer == 2)
|
|
|
|
return "Game.rgss2a";
|
|
|
|
else if (rgssVer == 3)
|
|
|
|
return "Game.rgss3a";
|
|
|
|
|
|
|
|
assert(!"unreachable");
|
|
|
|
return 0;
|
|
|
|
}
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
struct SharedStatePrivate
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
|
|
|
void *bindingData;
|
|
|
|
SDL_Window *sdlWindow;
|
|
|
|
Scene *screen;
|
|
|
|
|
|
|
|
FileSystem fileSystem;
|
|
|
|
|
|
|
|
EventThread &eThread;
|
|
|
|
RGSSThreadData &rtData;
|
|
|
|
Config &config;
|
|
|
|
|
2014-07-31 01:32:07 +00:00
|
|
|
SharedMidiState midiState;
|
|
|
|
|
2013-09-01 14:27:21 +00:00
|
|
|
Graphics graphics;
|
|
|
|
Input input;
|
|
|
|
Audio audio;
|
|
|
|
|
|
|
|
GLState _glState;
|
|
|
|
|
2013-12-11 04:22:13 +00:00
|
|
|
ShaderSet shaders;
|
2013-10-02 20:40:09 +00:00
|
|
|
|
2013-09-01 14:27:21 +00:00
|
|
|
TexPool texPool;
|
|
|
|
|
Font: Overhaul font asset discovery
Previously, any font names requested by RGSS would be translated
directly to filenames by lowercasing and replacing spaces with
underscores (and finally doing some extension substitution).
To make this whole thing work smoother as well as get closer to
how font discovery is done in VX, we now scan the "Fonts/" folder
at startup and index all present font assets by their family name;
now, if an "Open Sans" font is present in "Fonts/", it will be
used regardless of filename.
Font assets with "Regular" style are preferred, but in their
absence, mkxp will make use of any other style it can find for
the respective family. This is not the exact same behavior as
VX, but it should cover 95% of use cases.
Previously, one could substitute fonts via filenames, ie. to
substitute "Arial" with "Open Sans", one would just rename
"OpenSans.ttf" to "arial.ttf" and put it in "Fonts/". With the
above change, this is no longer possible. As an alternative, one
can now explicitly specify font family substitutions via mkxp.conf;
eg. for the above case, one would add
fontSub=Arial>Open Sans
to the configuration file. Multiple such rules can be specified.
In the process, I also added the ability to provide
'Font.(default_)name' with an array of font families to search
for the first existing one instead of a plain string.
This makes the behavior closer to RMXP; however, it doesn't
work 100% the same: when a reference to the 'Font.name' array is
held and additional strings are added to it without re-assignig
the array to 'Font.name', those will be ignored.
2014-04-11 11:37:14 +00:00
|
|
|
SharedFontState fontState;
|
2013-09-01 14:27:21 +00:00
|
|
|
Font *defaultFont;
|
|
|
|
|
2013-09-06 10:26:41 +00:00
|
|
|
TEX::ID globalTex;
|
2013-09-01 14:27:21 +00:00
|
|
|
int globalTexW, globalTexH;
|
|
|
|
|
2013-09-06 10:26:41 +00:00
|
|
|
TEXFBO gpTexFBO;
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2013-10-22 04:36:13 +00:00
|
|
|
TEXFBO atlasTex;
|
|
|
|
|
2013-09-04 17:07:28 +00:00
|
|
|
Quad gpQuad;
|
|
|
|
|
2013-09-01 14:27:21 +00:00
|
|
|
unsigned int stampCounter;
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
SharedStatePrivate(RGSSThreadData *threadData)
|
2013-09-01 14:27:21 +00:00
|
|
|
: bindingData(0),
|
|
|
|
sdlWindow(threadData->window),
|
2013-10-20 20:38:46 +00:00
|
|
|
fileSystem(threadData->argv0, threadData->config.allowSymlinks),
|
2013-09-01 14:27:21 +00:00
|
|
|
eThread(*threadData->ethread),
|
|
|
|
rtData(*threadData),
|
|
|
|
config(threadData->config),
|
2014-07-31 01:32:07 +00:00
|
|
|
midiState(threadData->config),
|
2013-09-01 14:27:21 +00:00
|
|
|
graphics(threadData),
|
2014-01-25 08:24:55 +00:00
|
|
|
input(*threadData),
|
2014-08-25 03:28:46 +00:00
|
|
|
audio(threadData->config),
|
Font: Overhaul font asset discovery
Previously, any font names requested by RGSS would be translated
directly to filenames by lowercasing and replacing spaces with
underscores (and finally doing some extension substitution).
To make this whole thing work smoother as well as get closer to
how font discovery is done in VX, we now scan the "Fonts/" folder
at startup and index all present font assets by their family name;
now, if an "Open Sans" font is present in "Fonts/", it will be
used regardless of filename.
Font assets with "Regular" style are preferred, but in their
absence, mkxp will make use of any other style it can find for
the respective family. This is not the exact same behavior as
VX, but it should cover 95% of use cases.
Previously, one could substitute fonts via filenames, ie. to
substitute "Arial" with "Open Sans", one would just rename
"OpenSans.ttf" to "arial.ttf" and put it in "Fonts/". With the
above change, this is no longer possible. As an alternative, one
can now explicitly specify font family substitutions via mkxp.conf;
eg. for the above case, one would add
fontSub=Arial>Open Sans
to the configuration file. Multiple such rules can be specified.
In the process, I also added the ability to provide
'Font.(default_)name' with an array of font families to search
for the first existing one instead of a plain string.
This makes the behavior closer to RMXP; however, it doesn't
work 100% the same: when a reference to the 'Font.name' array is
held and additional strings are added to it without re-assignig
the array to 'Font.name', those will be ignored.
2014-04-11 11:37:14 +00:00
|
|
|
fontState(threadData->config),
|
2013-09-01 14:27:21 +00:00
|
|
|
stampCounter(0)
|
|
|
|
{
|
2013-12-11 19:46:54 +00:00
|
|
|
if (!config.gameFolder.empty())
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
2013-12-30 00:26:39 +00:00
|
|
|
int result = chdir(config.gameFolder.c_str());
|
|
|
|
|
|
|
|
if (result != 0)
|
|
|
|
throw Exception(Exception::MKXPError,
|
|
|
|
"Unable to switch into gameFolder '%s'",
|
|
|
|
config.gameFolder.c_str());
|
2013-09-01 14:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME find out correct archive filename
|
2014-08-28 21:11:10 +00:00
|
|
|
std::string archPath = defGameArchive();
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2013-12-11 19:46:54 +00:00
|
|
|
/* Check if a game archive exists */
|
|
|
|
FILE *tmp = fopen(archPath.c_str(), "r");
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
fileSystem.addPath(archPath.c_str());
|
|
|
|
fclose(tmp);
|
|
|
|
}
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2014-08-22 21:58:14 +00:00
|
|
|
fileSystem.addPath(".");
|
|
|
|
|
2013-12-26 19:18:33 +00:00
|
|
|
for (size_t i = 0; i < config.rtps.size(); ++i)
|
2013-12-11 19:46:54 +00:00
|
|
|
fileSystem.addPath(config.rtps[i].c_str());
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2014-01-01 06:07:18 +00:00
|
|
|
if (config.pathCache)
|
|
|
|
fileSystem.createPathCache();
|
2013-09-30 19:19:43 +00:00
|
|
|
|
Font: Overhaul font asset discovery
Previously, any font names requested by RGSS would be translated
directly to filenames by lowercasing and replacing spaces with
underscores (and finally doing some extension substitution).
To make this whole thing work smoother as well as get closer to
how font discovery is done in VX, we now scan the "Fonts/" folder
at startup and index all present font assets by their family name;
now, if an "Open Sans" font is present in "Fonts/", it will be
used regardless of filename.
Font assets with "Regular" style are preferred, but in their
absence, mkxp will make use of any other style it can find for
the respective family. This is not the exact same behavior as
VX, but it should cover 95% of use cases.
Previously, one could substitute fonts via filenames, ie. to
substitute "Arial" with "Open Sans", one would just rename
"OpenSans.ttf" to "arial.ttf" and put it in "Fonts/". With the
above change, this is no longer possible. As an alternative, one
can now explicitly specify font family substitutions via mkxp.conf;
eg. for the above case, one would add
fontSub=Arial>Open Sans
to the configuration file. Multiple such rules can be specified.
In the process, I also added the ability to provide
'Font.(default_)name' with an array of font families to search
for the first existing one instead of a plain string.
This makes the behavior closer to RMXP; however, it doesn't
work 100% the same: when a reference to the 'Font.name' array is
held and additional strings are added to it without re-assignig
the array to 'Font.name', those will be ignored.
2014-04-11 11:37:14 +00:00
|
|
|
fileSystem.initFontSets(fontState);
|
|
|
|
|
2013-09-01 14:27:21 +00:00
|
|
|
globalTexW = 128;
|
|
|
|
globalTexH = 64;
|
|
|
|
|
2013-09-06 10:26:41 +00:00
|
|
|
globalTex = TEX::gen();
|
|
|
|
TEX::bind(globalTex);
|
|
|
|
TEX::setRepeat(false);
|
|
|
|
TEX::setSmooth(false);
|
|
|
|
TEX::allocEmpty(globalTexW, globalTexH);
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2013-09-06 10:26:41 +00:00
|
|
|
TEXFBO::init(gpTexFBO);
|
2013-09-01 14:27:21 +00:00
|
|
|
/* Reuse starting values */
|
2013-09-06 10:26:41 +00:00
|
|
|
TEXFBO::allocEmpty(gpTexFBO, globalTexW, globalTexH);
|
|
|
|
TEXFBO::linkFBO(gpTexFBO);
|
2014-07-31 01:32:07 +00:00
|
|
|
|
|
|
|
/* RGSS3 games will call setup_midi, so there's
|
|
|
|
* no need to do it on startup */
|
2014-08-28 21:11:10 +00:00
|
|
|
if (rgssVer <= 2)
|
2014-09-07 03:23:10 +00:00
|
|
|
midiState.initIfNeeded(threadData->config);
|
2013-09-01 14:27:21 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
~SharedStatePrivate()
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
2013-09-06 10:26:41 +00:00
|
|
|
TEX::del(globalTex);
|
|
|
|
TEXFBO::fini(gpTexFBO);
|
2013-10-22 04:36:13 +00:00
|
|
|
TEXFBO::fini(atlasTex);
|
2013-09-01 14:27:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
void SharedState::initInstance(RGSSThreadData *threadData)
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
2013-12-30 00:26:39 +00:00
|
|
|
/* This section is tricky because of dependencies:
|
|
|
|
* SharedState depends on GlobalIBO existing,
|
|
|
|
* Font depends on SharedState existing */
|
|
|
|
|
2014-08-28 21:11:10 +00:00
|
|
|
rgssVersion = threadData->config.rgssVersion;
|
|
|
|
Font::initDefaults();
|
|
|
|
|
2014-07-13 12:03:18 +00:00
|
|
|
_globalIBO = new GlobalIBO();
|
|
|
|
_globalIBO->ensureSize(1);
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2013-12-30 00:26:39 +00:00
|
|
|
SharedState::instance = 0;
|
|
|
|
Font *defaultFont = 0;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
SharedState::instance = new SharedState(threadData);
|
|
|
|
defaultFont = new Font();
|
|
|
|
}
|
|
|
|
catch (const Exception &exc)
|
|
|
|
{
|
2014-07-13 12:03:18 +00:00
|
|
|
delete _globalIBO;
|
2013-12-30 00:26:39 +00:00
|
|
|
delete SharedState::instance;
|
|
|
|
delete defaultFont;
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2013-12-30 00:26:39 +00:00
|
|
|
throw exc;
|
|
|
|
}
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2013-12-30 00:26:39 +00:00
|
|
|
SharedState::instance->p->defaultFont = defaultFont;
|
2013-09-01 14:27:21 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
void SharedState::finiInstance()
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
2013-10-09 10:30:33 +00:00
|
|
|
delete SharedState::instance->p->defaultFont;
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
delete SharedState::instance;
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2014-07-13 12:03:18 +00:00
|
|
|
delete _globalIBO;
|
2013-09-01 14:27:21 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
void SharedState::setScreen(Scene &screen)
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
|
|
|
p->screen = &screen;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GSATT(type, lower) \
|
2014-08-12 18:33:40 +00:00
|
|
|
type SharedState :: lower() const \
|
2013-09-01 14:27:21 +00:00
|
|
|
{ \
|
|
|
|
return p->lower; \
|
|
|
|
}
|
|
|
|
|
|
|
|
GSATT(void*, bindingData)
|
|
|
|
GSATT(SDL_Window*, sdlWindow)
|
|
|
|
GSATT(Scene*, screen)
|
|
|
|
GSATT(FileSystem&, fileSystem)
|
|
|
|
GSATT(EventThread&, eThread)
|
|
|
|
GSATT(RGSSThreadData&, rtData)
|
|
|
|
GSATT(Config&, config)
|
|
|
|
GSATT(Graphics&, graphics)
|
|
|
|
GSATT(Input&, input)
|
|
|
|
GSATT(Audio&, audio)
|
|
|
|
GSATT(GLState&, _glState)
|
2013-12-11 04:22:13 +00:00
|
|
|
GSATT(ShaderSet&, shaders)
|
2013-09-01 14:27:21 +00:00
|
|
|
GSATT(TexPool&, texPool)
|
2013-09-04 17:07:28 +00:00
|
|
|
GSATT(Quad&, gpQuad)
|
Font: Overhaul font asset discovery
Previously, any font names requested by RGSS would be translated
directly to filenames by lowercasing and replacing spaces with
underscores (and finally doing some extension substitution).
To make this whole thing work smoother as well as get closer to
how font discovery is done in VX, we now scan the "Fonts/" folder
at startup and index all present font assets by their family name;
now, if an "Open Sans" font is present in "Fonts/", it will be
used regardless of filename.
Font assets with "Regular" style are preferred, but in their
absence, mkxp will make use of any other style it can find for
the respective family. This is not the exact same behavior as
VX, but it should cover 95% of use cases.
Previously, one could substitute fonts via filenames, ie. to
substitute "Arial" with "Open Sans", one would just rename
"OpenSans.ttf" to "arial.ttf" and put it in "Fonts/". With the
above change, this is no longer possible. As an alternative, one
can now explicitly specify font family substitutions via mkxp.conf;
eg. for the above case, one would add
fontSub=Arial>Open Sans
to the configuration file. Multiple such rules can be specified.
In the process, I also added the ability to provide
'Font.(default_)name' with an array of font families to search
for the first existing one instead of a plain string.
This makes the behavior closer to RMXP; however, it doesn't
work 100% the same: when a reference to the 'Font.name' array is
held and additional strings are added to it without re-assignig
the array to 'Font.name', those will be ignored.
2014-04-11 11:37:14 +00:00
|
|
|
GSATT(SharedFontState&, fontState)
|
2014-07-31 01:32:07 +00:00
|
|
|
GSATT(SharedMidiState&, midiState)
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
void SharedState::setBindingData(void *data)
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
|
|
|
p->bindingData = data;
|
|
|
|
}
|
|
|
|
|
2014-08-12 17:46:30 +00:00
|
|
|
void SharedState::ensureQuadIBO(size_t minSize)
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
2014-07-13 12:03:18 +00:00
|
|
|
_globalIBO->ensureSize(minSize);
|
2013-09-01 14:27:21 +00:00
|
|
|
}
|
|
|
|
|
2014-07-13 12:03:18 +00:00
|
|
|
GlobalIBO &SharedState::globalIBO()
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
2014-07-13 12:03:18 +00:00
|
|
|
return *_globalIBO;
|
2013-09-01 14:27:21 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
void SharedState::bindTex()
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
2013-09-06 10:26:41 +00:00
|
|
|
TEX::bind(p->globalTex);
|
|
|
|
TEX::allocEmpty(p->globalTexW, p->globalTexH);
|
2013-09-01 14:27:21 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
|
|
|
if (minW > p->globalTexW)
|
|
|
|
p->globalTexW = findNextPow2(minW);
|
|
|
|
|
|
|
|
if (minH > p->globalTexH)
|
|
|
|
p->globalTexH = findNextPow2(minH);
|
|
|
|
|
2013-09-23 05:15:01 +00:00
|
|
|
currentSizeOut = Vec2i(p->globalTexW, p->globalTexH);
|
2013-09-01 14:27:21 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
TEXFBO &SharedState::gpTexFBO(int minW, int minH)
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
|
|
|
bool needResize = false;
|
|
|
|
|
|
|
|
if (minW > p->gpTexFBO.width)
|
|
|
|
{
|
|
|
|
p->gpTexFBO.width = findNextPow2(minW);
|
|
|
|
needResize = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (minH > p->gpTexFBO.height)
|
|
|
|
{
|
|
|
|
p->gpTexFBO.height = findNextPow2(minH);
|
|
|
|
needResize = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needResize)
|
|
|
|
{
|
2013-09-06 10:26:41 +00:00
|
|
|
TEX::bind(p->gpTexFBO.tex);
|
|
|
|
TEX::allocEmpty(p->gpTexFBO.width, p->gpTexFBO.height);
|
2013-09-01 14:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return p->gpTexFBO;
|
|
|
|
}
|
|
|
|
|
2013-10-22 04:36:13 +00:00
|
|
|
void SharedState::requestAtlasTex(int w, int h, TEXFBO &out)
|
|
|
|
{
|
|
|
|
TEXFBO tex;
|
|
|
|
|
|
|
|
if (w == p->atlasTex.width && h == p->atlasTex.height)
|
|
|
|
{
|
|
|
|
tex = p->atlasTex;
|
|
|
|
p->atlasTex = TEXFBO();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TEXFBO::init(tex);
|
|
|
|
TEXFBO::allocEmpty(tex, w, h);
|
|
|
|
TEXFBO::linkFBO(tex);
|
|
|
|
}
|
|
|
|
|
|
|
|
out = tex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SharedState::releaseAtlasTex(TEXFBO &tex)
|
|
|
|
{
|
|
|
|
/* No point in caching an invalid object */
|
|
|
|
if (tex.tex == TEX::ID(0))
|
|
|
|
return;
|
|
|
|
|
|
|
|
TEXFBO::fini(p->atlasTex);
|
|
|
|
|
|
|
|
p->atlasTex = tex;
|
|
|
|
}
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
void SharedState::checkShutdown()
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
|
|
|
if (!p->rtData.rqTerm)
|
|
|
|
return;
|
|
|
|
|
2014-08-24 05:36:19 +00:00
|
|
|
p->rtData.rqTermAck.set();
|
2013-09-01 14:27:21 +00:00
|
|
|
p->texPool.disable();
|
|
|
|
scriptBinding->terminate();
|
|
|
|
}
|
|
|
|
|
2014-08-24 05:36:19 +00:00
|
|
|
void SharedState::checkReset()
|
|
|
|
{
|
|
|
|
if (!p->rtData.rqReset)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p->rtData.rqReset.clear();
|
|
|
|
scriptBinding->reset();
|
|
|
|
}
|
|
|
|
|
2014-08-12 18:33:40 +00:00
|
|
|
Font &SharedState::defaultFont() const
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
|
|
|
return *p->defaultFont;
|
|
|
|
}
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
unsigned int SharedState::genTimeStamp()
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
|
|
|
return p->stampCounter++;
|
|
|
|
}
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
SharedState::SharedState(RGSSThreadData *threadData)
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
2013-10-09 10:30:33 +00:00
|
|
|
p = new SharedStatePrivate(threadData);
|
2013-09-01 14:27:21 +00:00
|
|
|
p->screen = p->graphics.getScreen();
|
|
|
|
}
|
|
|
|
|
2013-10-09 10:30:33 +00:00
|
|
|
SharedState::~SharedState()
|
2013-09-01 14:27:21 +00:00
|
|
|
{
|
|
|
|
delete p;
|
|
|
|
}
|