|
|
@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
|
|
|
|
#include "Internal.h"
|
|
|
|
#include "Internal.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "modules/DFSDL.h"
|
|
|
|
#include "modules/DFSDL.h"
|
|
|
@ -5,8 +8,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "Debug.h"
|
|
|
|
#include "Debug.h"
|
|
|
|
#include "PluginManager.h"
|
|
|
|
#include "PluginManager.h"
|
|
|
|
|
|
|
|
#include "VTableInterpose.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "df/enabler.h"
|
|
|
|
#include "df/enabler.h"
|
|
|
|
|
|
|
|
#include "df/viewscreen_adopt_regionst.h"
|
|
|
|
|
|
|
|
#include "df/viewscreen_loadgamest.h"
|
|
|
|
|
|
|
|
#include "df/viewscreen_new_arenast.h"
|
|
|
|
|
|
|
|
#include "df/viewscreen_new_regionst.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <SDL_surface.h>
|
|
|
|
#include <SDL_surface.h>
|
|
|
|
|
|
|
|
|
|
|
@ -15,24 +23,12 @@ using namespace DFHack;
|
|
|
|
using namespace DFHack::DFSDL;
|
|
|
|
using namespace DFHack::DFSDL;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DFHack {
|
|
|
|
namespace DFHack {
|
|
|
|
DBG_DECLARE(core, textures, DebugCategory::LINFO);
|
|
|
|
DBG_DECLARE(core, textures, DebugCategory::LINFO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool g_loaded = false;
|
|
|
|
static std::unordered_map<TexposHandle, long> g_handle_to_texpos;
|
|
|
|
static long g_num_dfhack_textures = 0;
|
|
|
|
static std::unordered_map<TexposHandle, SDL_Surface*> g_handle_to_surface;
|
|
|
|
static long g_dfhack_logo_texpos_start = -1;
|
|
|
|
static std::mutex g_adding_mutex;
|
|
|
|
static long g_green_pin_texpos_start = -1;
|
|
|
|
|
|
|
|
static long g_red_pin_texpos_start = -1;
|
|
|
|
|
|
|
|
static long g_icons_texpos_start = -1;
|
|
|
|
|
|
|
|
static long g_on_off_texpos_start = -1;
|
|
|
|
|
|
|
|
static long g_pathable_texpos_start = -1;
|
|
|
|
|
|
|
|
static long g_unsuspend_texpos_start = -1;
|
|
|
|
|
|
|
|
static long g_control_panel_texpos_start = -1;
|
|
|
|
|
|
|
|
static long g_thin_borders_texpos_start = -1;
|
|
|
|
|
|
|
|
static long g_medium_borders_texpos_start = -1;
|
|
|
|
|
|
|
|
static long g_bold_borders_texpos_start = -1;
|
|
|
|
|
|
|
|
static long g_panel_borders_texpos_start = -1;
|
|
|
|
|
|
|
|
static long g_window_borders_texpos_start = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Converts an arbitrary Surface to something like the display format
|
|
|
|
// Converts an arbitrary Surface to something like the display format
|
|
|
|
// (32-bit RGBA), and converts magenta to transparency if convert_magenta is set
|
|
|
|
// (32-bit RGBA), and converts magenta to transparency if convert_magenta is set
|
|
|
@ -41,23 +37,29 @@ static long g_window_borders_texpos_start = -1;
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// It uses the same pixel format (RGBA, R at lowest address) regardless of
|
|
|
|
// It uses the same pixel format (RGBA, R at lowest address) regardless of
|
|
|
|
// hardware.
|
|
|
|
// hardware.
|
|
|
|
SDL_Surface * canonicalize_format(SDL_Surface *src) {
|
|
|
|
SDL_Surface* canonicalize_format(SDL_Surface* src) {
|
|
|
|
SDL_PixelFormat fmt;
|
|
|
|
SDL_PixelFormat fmt;
|
|
|
|
fmt.palette = NULL;
|
|
|
|
fmt.palette = NULL;
|
|
|
|
fmt.BitsPerPixel = 32;
|
|
|
|
fmt.BitsPerPixel = 32;
|
|
|
|
fmt.BytesPerPixel = 4;
|
|
|
|
fmt.BytesPerPixel = 4;
|
|
|
|
fmt.Rloss = fmt.Gloss = fmt.Bloss = fmt.Aloss = 0;
|
|
|
|
fmt.Rloss = fmt.Gloss = fmt.Bloss = fmt.Aloss = 0;
|
|
|
|
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
|
|
|
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
|
|
|
fmt.Rshift = 24; fmt.Gshift = 16; fmt.Bshift = 8; fmt.Ashift = 0;
|
|
|
|
fmt.Rshift = 24;
|
|
|
|
|
|
|
|
fmt.Gshift = 16;
|
|
|
|
|
|
|
|
fmt.Bshift = 8;
|
|
|
|
|
|
|
|
fmt.Ashift = 0;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
fmt.Rshift = 0; fmt.Gshift = 8; fmt.Bshift = 16; fmt.Ashift = 24;
|
|
|
|
fmt.Rshift = 0;
|
|
|
|
|
|
|
|
fmt.Gshift = 8;
|
|
|
|
|
|
|
|
fmt.Bshift = 16;
|
|
|
|
|
|
|
|
fmt.Ashift = 24;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
fmt.Rmask = 255 << fmt.Rshift;
|
|
|
|
fmt.Rmask = 255 << fmt.Rshift;
|
|
|
|
fmt.Gmask = 255 << fmt.Gshift;
|
|
|
|
fmt.Gmask = 255 << fmt.Gshift;
|
|
|
|
fmt.Bmask = 255 << fmt.Bshift;
|
|
|
|
fmt.Bmask = 255 << fmt.Bshift;
|
|
|
|
fmt.Amask = 255 << fmt.Ashift;
|
|
|
|
fmt.Amask = 255 << fmt.Ashift;
|
|
|
|
|
|
|
|
|
|
|
|
SDL_Surface *tgt = DFSDL_ConvertSurface(src, &fmt, SDL_SWSURFACE);
|
|
|
|
SDL_Surface* tgt = DFSDL_ConvertSurface(src, &fmt, SDL_SWSURFACE);
|
|
|
|
DFSDL_FreeSurface(src);
|
|
|
|
DFSDL_FreeSurface(src);
|
|
|
|
for (int x = 0; x < tgt->w; ++x) {
|
|
|
|
for (int x = 0; x < tgt->w; ++x) {
|
|
|
|
for (int y = 0; y < tgt->h; ++y) {
|
|
|
|
for (int y = 0; y < tgt->h; ++y) {
|
|
|
@ -72,174 +74,178 @@ SDL_Surface * canonicalize_format(SDL_Surface *src) {
|
|
|
|
return tgt;
|
|
|
|
return tgt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const uint32_t TILE_WIDTH_PX = 8;
|
|
|
|
// register surface in texture raws, get a texpos
|
|
|
|
const uint32_t TILE_HEIGHT_PX = 12;
|
|
|
|
static long add_texture(SDL_Surface* surface) {
|
|
|
|
|
|
|
|
std::lock_guard<std::mutex> lg_add_texture(g_adding_mutex);
|
|
|
|
|
|
|
|
auto texpos = enabler->textures.raws.size();
|
|
|
|
|
|
|
|
enabler->textures.raws.push_back(surface);
|
|
|
|
|
|
|
|
return texpos;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TexposHandle Textures::loadTexture(SDL_Surface* surface) {
|
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
|
|
|
|
return 0; // should be some error, i guess
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto handle = reinterpret_cast<uintptr_t>(surface);
|
|
|
|
|
|
|
|
g_handle_to_surface.emplace(handle, surface);
|
|
|
|
|
|
|
|
surface->refcount++; // prevent destruct on next FreeSurface by game
|
|
|
|
|
|
|
|
auto texpos = add_texture(surface);
|
|
|
|
|
|
|
|
g_handle_to_texpos.emplace(handle, texpos);
|
|
|
|
|
|
|
|
return handle;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static size_t load_textures(color_ostream & out, const char * fname,
|
|
|
|
std::vector<TexposHandle> Textures::loadTileset(const std::string& file, int tile_px_w,
|
|
|
|
long *texpos_start,
|
|
|
|
int tile_px_h) {
|
|
|
|
int tile_w = TILE_WIDTH_PX,
|
|
|
|
std::vector<TexposHandle> handles{};
|
|
|
|
int tile_h = TILE_HEIGHT_PX) {
|
|
|
|
|
|
|
|
SDL_Surface *s = DFIMG_Load(fname);
|
|
|
|
SDL_Surface* surface = DFIMG_Load(file.c_str());
|
|
|
|
if (!s) {
|
|
|
|
if (!surface) {
|
|
|
|
out.printerr("unable to load textures from '%s'\n", fname);
|
|
|
|
ERR(textures).printerr("unable to load textures from '%s'\n", file.c_str());
|
|
|
|
return 0;
|
|
|
|
return handles;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
s = canonicalize_format(s);
|
|
|
|
surface = canonicalize_format(surface);
|
|
|
|
int dimx = s->w / tile_w;
|
|
|
|
int dimx = surface->w / tile_px_w;
|
|
|
|
int dimy = s->h / tile_h;
|
|
|
|
int dimy = surface->h / tile_px_h;
|
|
|
|
long count = 0;
|
|
|
|
|
|
|
|
for (int y = 0; y < dimy; y++) {
|
|
|
|
for (int y = 0; y < dimy; y++) {
|
|
|
|
for (int x = 0; x < dimx; x++) {
|
|
|
|
for (int x = 0; x < dimx; x++) {
|
|
|
|
SDL_Surface *tile = DFSDL_CreateRGBSurface(0, // SDL_SWSURFACE
|
|
|
|
SDL_Surface* tile = DFSDL_CreateRGBSurface(
|
|
|
|
tile_w, tile_h, 32,
|
|
|
|
0, tile_px_w, tile_px_h, 32, surface->format->Rmask, surface->format->Gmask,
|
|
|
|
s->format->Rmask, s->format->Gmask, s->format->Bmask,
|
|
|
|
surface->format->Bmask, surface->format->Amask);
|
|
|
|
s->format->Amask);
|
|
|
|
SDL_Rect vp{tile_px_w * x, tile_px_h * y, tile_px_w, tile_px_h};
|
|
|
|
SDL_Rect vp;
|
|
|
|
DFSDL_UpperBlit(surface, &vp, tile, NULL);
|
|
|
|
vp.x = tile_w * x;
|
|
|
|
auto handle = Textures::loadTexture(tile);
|
|
|
|
vp.y = tile_h * y;
|
|
|
|
handles.push_back(handle);
|
|
|
|
vp.w = tile_w;
|
|
|
|
}
|
|
|
|
vp.h = tile_h;
|
|
|
|
}
|
|
|
|
DFSDL_UpperBlit(s, &vp, tile, NULL);
|
|
|
|
|
|
|
|
if (!count++)
|
|
|
|
|
|
|
|
*texpos_start = enabler->textures.raws.size();
|
|
|
|
|
|
|
|
enabler->textures.raws.push_back(tile);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DFSDL_FreeSurface(s);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG(textures,out).print("loaded %ld textures from '%s'\n", count, fname);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DFHack could conceivably be loaded at any time, so we need to be able to
|
|
|
|
DFSDL_FreeSurface(surface);
|
|
|
|
// handle loading textures before or after a world is loaded.
|
|
|
|
DEBUG(textures).print("loaded %zd textures from '%s'\n", handles.size(), file.c_str());
|
|
|
|
// If a world is already loaded, then append our textures to the raws. they'll
|
|
|
|
|
|
|
|
// be freed when the world is unloaded and we'll reload when we get to the title
|
|
|
|
return handles;
|
|
|
|
// screen. If it's pre-world, append our textures and then adjust the "init"
|
|
|
|
|
|
|
|
// texture count so our textures will no longer be freed when worlds are
|
|
|
|
|
|
|
|
// unloaded.
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
void Textures::init(color_ostream &out) {
|
|
|
|
|
|
|
|
if (!enabler)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto & textures = enabler->textures;
|
|
|
|
|
|
|
|
long num_textures = textures.raws.size();
|
|
|
|
|
|
|
|
if (num_textures <= g_dfhack_logo_texpos_start)
|
|
|
|
|
|
|
|
g_loaded = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (g_loaded)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool is_pre_world = num_textures == textures.init_texture_size;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_num_dfhack_textures = load_textures(out, "hack/data/art/dfhack.png",
|
|
|
|
|
|
|
|
&g_dfhack_logo_texpos_start);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/green-pin.png",
|
|
|
|
|
|
|
|
&g_green_pin_texpos_start);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/red-pin.png",
|
|
|
|
|
|
|
|
&g_red_pin_texpos_start);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/icons.png",
|
|
|
|
|
|
|
|
&g_icons_texpos_start);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/on-off.png",
|
|
|
|
|
|
|
|
&g_on_off_texpos_start);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/pathable.png",
|
|
|
|
|
|
|
|
&g_pathable_texpos_start, 32, 32);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/unsuspend.png",
|
|
|
|
|
|
|
|
&g_unsuspend_texpos_start, 32, 32);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/control-panel.png",
|
|
|
|
|
|
|
|
&g_control_panel_texpos_start);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/border-thin.png",
|
|
|
|
|
|
|
|
&g_thin_borders_texpos_start);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/border-medium.png",
|
|
|
|
|
|
|
|
&g_medium_borders_texpos_start);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/border-bold.png",
|
|
|
|
|
|
|
|
&g_bold_borders_texpos_start);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/border-panel.png",
|
|
|
|
|
|
|
|
&g_panel_borders_texpos_start);
|
|
|
|
|
|
|
|
g_num_dfhack_textures += load_textures(out, "hack/data/art/border-window.png",
|
|
|
|
|
|
|
|
&g_window_borders_texpos_start);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG(textures,out).print("loaded %ld textures\n", g_num_dfhack_textures);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (is_pre_world)
|
|
|
|
|
|
|
|
textures.init_texture_size += g_num_dfhack_textures;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: when GL modes are supported, we'll have to re-upload textures here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_loaded = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// It's ok to leave NULLs in the raws list (according to usage in g_src)
|
|
|
|
long Textures::getTexposByHandle(TexposHandle handle) {
|
|
|
|
void Textures::cleanup() {
|
|
|
|
if (!handle)
|
|
|
|
if (!g_loaded)
|
|
|
|
return -1;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto & textures = enabler->textures;
|
|
|
|
if (g_handle_to_texpos.contains(handle))
|
|
|
|
auto &raws = textures.raws;
|
|
|
|
return g_handle_to_texpos[handle];
|
|
|
|
size_t texpos_end = g_dfhack_logo_texpos_start + g_num_dfhack_textures - 1;
|
|
|
|
|
|
|
|
for (size_t idx = g_dfhack_logo_texpos_start; idx <= texpos_end; ++idx) {
|
|
|
|
|
|
|
|
DFSDL_FreeSurface((SDL_Surface *)raws[idx]);
|
|
|
|
|
|
|
|
raws[idx] = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (g_dfhack_logo_texpos_start == textures.init_texture_size - g_num_dfhack_textures)
|
|
|
|
if (g_handle_to_surface.contains(handle)) {
|
|
|
|
textures.init_texture_size -= g_num_dfhack_textures;
|
|
|
|
g_handle_to_surface[handle]->refcount++; // prevent destruct on next FreeSurface by game
|
|
|
|
|
|
|
|
auto texpos = add_texture(g_handle_to_surface[handle]);
|
|
|
|
|
|
|
|
g_handle_to_texpos.emplace(handle, texpos);
|
|
|
|
|
|
|
|
return texpos;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
g_loaded = false;
|
|
|
|
return -1;
|
|
|
|
g_num_dfhack_textures = 0;
|
|
|
|
|
|
|
|
g_dfhack_logo_texpos_start = -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getDfhackLogoTexposStart() {
|
|
|
|
static void reset_texpos() {
|
|
|
|
return g_dfhack_logo_texpos_start;
|
|
|
|
g_handle_to_texpos.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getGreenPinTexposStart() {
|
|
|
|
static void reset_surface() {
|
|
|
|
return g_green_pin_texpos_start;
|
|
|
|
for (auto& entry : g_handle_to_surface) {
|
|
|
|
|
|
|
|
DFSDL_FreeSurface(entry.second);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_handle_to_surface.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getRedPinTexposStart() {
|
|
|
|
// reset point on New Game
|
|
|
|
return g_red_pin_texpos_start;
|
|
|
|
struct tracking_stage_new_region : df::viewscreen_new_regionst {
|
|
|
|
}
|
|
|
|
typedef df::viewscreen_new_regionst interpose_base;
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getIconsTexposStart() {
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, logic, ()) {
|
|
|
|
return g_icons_texpos_start;
|
|
|
|
if (this->m_raw_load_stage != this->raw_load_stage) {
|
|
|
|
}
|
|
|
|
this->m_raw_load_stage = this->raw_load_stage;
|
|
|
|
|
|
|
|
if (this->m_raw_load_stage == 1)
|
|
|
|
|
|
|
|
reset_texpos();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERPOSE_NEXT(logic)();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getOnOffTexposStart() {
|
|
|
|
private:
|
|
|
|
return g_on_off_texpos_start;
|
|
|
|
inline static int m_raw_load_stage = -2; // not valid state at the start
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(tracking_stage_new_region, logic);
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getMapPathableTexposStart() {
|
|
|
|
// reset point on New Game in Existing World
|
|
|
|
return g_pathable_texpos_start;
|
|
|
|
struct tracking_stage_adopt_region : df::viewscreen_adopt_regionst {
|
|
|
|
}
|
|
|
|
typedef df::viewscreen_adopt_regionst interpose_base;
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getMapUnsuspendTexposStart() {
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, logic, ()) {
|
|
|
|
return g_unsuspend_texpos_start;
|
|
|
|
if (this->m_cur_step != this->cur_step) {
|
|
|
|
}
|
|
|
|
this->m_cur_step = this->cur_step;
|
|
|
|
|
|
|
|
if (this->m_cur_step == 1)
|
|
|
|
|
|
|
|
reset_texpos();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERPOSE_NEXT(logic)();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getControlPanelTexposStart() {
|
|
|
|
private:
|
|
|
|
return g_control_panel_texpos_start;
|
|
|
|
inline static int m_cur_step = -2; // not valid state at the start
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(tracking_stage_adopt_region, logic);
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getThinBordersTexposStart() {
|
|
|
|
// reset point on Load Game
|
|
|
|
return g_thin_borders_texpos_start;
|
|
|
|
struct tracking_stage_load_region : df::viewscreen_loadgamest {
|
|
|
|
}
|
|
|
|
typedef df::viewscreen_loadgamest interpose_base;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, logic, ()) {
|
|
|
|
|
|
|
|
if (this->m_cur_step != this->cur_step) {
|
|
|
|
|
|
|
|
this->m_cur_step = this->cur_step;
|
|
|
|
|
|
|
|
if (this->m_cur_step == 1)
|
|
|
|
|
|
|
|
reset_texpos();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERPOSE_NEXT(logic)();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
inline static int m_cur_step = -2; // not valid state at the start
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(tracking_stage_load_region, logic);
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getMediumBordersTexposStart() {
|
|
|
|
// reset point on New Arena
|
|
|
|
return g_medium_borders_texpos_start;
|
|
|
|
struct tracking_stage_new_arena : df::viewscreen_new_arenast {
|
|
|
|
|
|
|
|
typedef df::viewscreen_new_arenast interpose_base;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, logic, ()) {
|
|
|
|
|
|
|
|
if (this->m_cur_step != this->cur_step) {
|
|
|
|
|
|
|
|
this->m_cur_step = this->cur_step;
|
|
|
|
|
|
|
|
if (this->m_cur_step == 0)
|
|
|
|
|
|
|
|
reset_texpos();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERPOSE_NEXT(logic)();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
inline static int m_cur_step = -2; // not valid state at the start
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(tracking_stage_new_arena, logic);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void install_reset_point() {
|
|
|
|
|
|
|
|
INTERPOSE_HOOK(tracking_stage_new_region, logic).apply();
|
|
|
|
|
|
|
|
INTERPOSE_HOOK(tracking_stage_adopt_region, logic).apply();
|
|
|
|
|
|
|
|
INTERPOSE_HOOK(tracking_stage_load_region, logic).apply();
|
|
|
|
|
|
|
|
INTERPOSE_HOOK(tracking_stage_new_arena, logic).apply();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getBoldBordersTexposStart() {
|
|
|
|
static void uninstall_reset_point() {
|
|
|
|
return g_bold_borders_texpos_start;
|
|
|
|
INTERPOSE_HOOK(tracking_stage_new_region, logic).remove();
|
|
|
|
|
|
|
|
INTERPOSE_HOOK(tracking_stage_adopt_region, logic).remove();
|
|
|
|
|
|
|
|
INTERPOSE_HOOK(tracking_stage_load_region, logic).remove();
|
|
|
|
|
|
|
|
INTERPOSE_HOOK(tracking_stage_new_arena, logic).remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getPanelBordersTexposStart() {
|
|
|
|
void Textures::init(color_ostream& out) {
|
|
|
|
return g_panel_borders_texpos_start;
|
|
|
|
install_reset_point();
|
|
|
|
|
|
|
|
DEBUG(textures, out).print("dynamic texture loading ready");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long Textures::getWindowBordersTexposStart() {
|
|
|
|
void Textures::cleanup() {
|
|
|
|
return g_window_borders_texpos_start;
|
|
|
|
reset_texpos();
|
|
|
|
|
|
|
|
reset_surface();
|
|
|
|
|
|
|
|
uninstall_reset_point();
|
|
|
|
}
|
|
|
|
}
|
|
|
|