Merge branch 'rm-old-modules' into develop
commit
4cdb0ff138
@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
https://github.com/peterix/dfhack
|
|
||||||
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any
|
|
||||||
damages arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any
|
|
||||||
purpose, including commercial applications, and to alter it and
|
|
||||||
redistribute it freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must
|
|
||||||
not claim that you wrote the original software. If you use this
|
|
||||||
software in a product, an acknowledgment in the product documentation
|
|
||||||
would be appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and
|
|
||||||
must not be misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include "Core.h"
|
|
||||||
#include "Hooks.h"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
// hook - called before rendering
|
|
||||||
DFhackCExport int egg_init(void)
|
|
||||||
{
|
|
||||||
// reroute stderr
|
|
||||||
freopen("stderr.log", "w", stderr);
|
|
||||||
// we don't reroute stdout until we figure out if this should be done at all
|
|
||||||
// See: Console-linux.cpp
|
|
||||||
fprintf(stderr,"dfhack: hooking successful\n");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// hook - called before rendering
|
|
||||||
DFhackCExport int egg_shutdown(void)
|
|
||||||
{
|
|
||||||
DFHack::Core & c = DFHack::Core::getInstance();
|
|
||||||
return c.Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
// hook - called for each game tick (or more often)
|
|
||||||
DFhackCExport int egg_tick(void)
|
|
||||||
{
|
|
||||||
DFHack::Core & c = DFHack::Core::getInstance();
|
|
||||||
return c.Update();
|
|
||||||
}
|
|
||||||
// hook - called before rendering
|
|
||||||
DFhackCExport int egg_prerender(void)
|
|
||||||
{
|
|
||||||
DFHack::Core & c = DFHack::Core::getInstance();
|
|
||||||
return c.TileUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
// hook - called for each SDL event, returns 0 when the event has been consumed. 1 otherwise
|
|
||||||
DFhackCExport int egg_sdl_event(SDL::Event* event)
|
|
||||||
{
|
|
||||||
// if the event is valid, intercept
|
|
||||||
if( event != 0 )
|
|
||||||
{
|
|
||||||
DFHack::Core & c = DFHack::Core::getInstance();
|
|
||||||
return c.DFH_SDL_Event(event);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return this if you want to kill the event.
|
|
||||||
const int curses_error = -1;
|
|
||||||
// hook - ncurses event, -1 signifies error.
|
|
||||||
DFhackCExport int egg_curses_event(int orig_return)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
if(orig_return != -1)
|
|
||||||
{
|
|
||||||
DFHack::Core & c = DFHack::Core::getInstance();
|
|
||||||
int out;
|
|
||||||
return c.ncurses_wgetch(orig_return,);
|
|
||||||
}*/
|
|
||||||
return orig_return;
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
https://github.com/peterix/dfhack
|
|
||||||
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any
|
|
||||||
damages arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any
|
|
||||||
purpose, including commercial applications, and to alter it and
|
|
||||||
redistribute it freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must
|
|
||||||
not claim that you wrote the original software. If you use this
|
|
||||||
software in a product, an acknowledgment in the product documentation
|
|
||||||
would be appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and
|
|
||||||
must not be misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#ifndef CL_MOD_ENGRAVINGS
|
|
||||||
#define CL_MOD_ENGRAVINGS
|
|
||||||
/*
|
|
||||||
* DF engravings
|
|
||||||
*/
|
|
||||||
#include "Export.h"
|
|
||||||
#include "DataDefs.h"
|
|
||||||
#include "df/engraving.h"
|
|
||||||
/**
|
|
||||||
* \defgroup grp_engraving Engraving module parts
|
|
||||||
* @ingroup grp_modules
|
|
||||||
*/
|
|
||||||
namespace DFHack
|
|
||||||
{
|
|
||||||
namespace Engravings
|
|
||||||
{
|
|
||||||
// "Simplified" copy of engraving
|
|
||||||
struct t_engraving {
|
|
||||||
int32_t artist;
|
|
||||||
int32_t masterpiece_event;
|
|
||||||
int32_t skill_rating;
|
|
||||||
df::coord pos;
|
|
||||||
df::engraving_flags flags;
|
|
||||||
int8_t tile;
|
|
||||||
int32_t art_id;
|
|
||||||
int16_t art_subid;
|
|
||||||
df::item_quality quality;
|
|
||||||
// Pointer to original object, in case you want to modify it
|
|
||||||
df::engraving *origin;
|
|
||||||
};
|
|
||||||
|
|
||||||
DFHACK_EXPORT bool isValid();
|
|
||||||
DFHACK_EXPORT uint32_t getCount();
|
|
||||||
DFHACK_EXPORT bool copyEngraving (const int32_t index, t_engraving &out);
|
|
||||||
DFHACK_EXPORT df::engraving * getEngraving (const int32_t index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,65 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#ifndef CL_MOD_NOTES
|
|
||||||
#define CL_MOD_NOTES
|
|
||||||
/**
|
|
||||||
* \defgroup grp_notes In game notes (and routes)
|
|
||||||
* @ingroup grp_notes
|
|
||||||
*/
|
|
||||||
#include "Export.h"
|
|
||||||
#include "Module.h"
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
namespace DFHack
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
/**
|
|
||||||
* Game's structure for a note.
|
|
||||||
* \ingroup grp_notes
|
|
||||||
*/
|
|
||||||
struct t_note
|
|
||||||
{
|
|
||||||
// First note created has id 0, second has id 1, etc. Not affected
|
|
||||||
// by lower id notes being deleted.
|
|
||||||
uint32_t id; // 0
|
|
||||||
uint8_t symbol; // 4
|
|
||||||
uint8_t unk1; // alignment padding?
|
|
||||||
uint16_t foreground; // 6
|
|
||||||
uint16_t background; // 8
|
|
||||||
uint16_t unk2; // alignment padding?
|
|
||||||
|
|
||||||
std::string name; // C
|
|
||||||
std::string text; // 10
|
|
||||||
|
|
||||||
uint16_t x; // 14
|
|
||||||
uint16_t y; // 16
|
|
||||||
uint16_t z; // 18
|
|
||||||
|
|
||||||
// Is there more?
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The notes module - allows reading DF in-game notes
|
|
||||||
* \ingroup grp_modules
|
|
||||||
* \ingroup grp_notes
|
|
||||||
*/
|
|
||||||
class DFHACK_EXPORT Notes : public Module
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Notes();
|
|
||||||
~Notes(){};
|
|
||||||
bool Finish()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
std::vector<t_note*>* notes;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,270 +0,0 @@
|
|||||||
/*
|
|
||||||
https://github.com/peterix/dfhack
|
|
||||||
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any
|
|
||||||
damages arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any
|
|
||||||
purpose, including commercial applications, and to alter it and
|
|
||||||
redistribute it freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must
|
|
||||||
not claim that you wrote the original software. If you use this
|
|
||||||
software in a product, an acknowledgment in the product documentation
|
|
||||||
would be appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and
|
|
||||||
must not be misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "Export.h"
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
namespace DFHack
|
|
||||||
{
|
|
||||||
namespace Windows
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* DF window stuffs
|
|
||||||
*/
|
|
||||||
enum df_color
|
|
||||||
{
|
|
||||||
black,
|
|
||||||
blue,
|
|
||||||
green,
|
|
||||||
cyan,
|
|
||||||
red,
|
|
||||||
magenta,
|
|
||||||
brown,
|
|
||||||
lgray,
|
|
||||||
dgray,
|
|
||||||
lblue,
|
|
||||||
lgreen,
|
|
||||||
lcyan,
|
|
||||||
lred,
|
|
||||||
lmagenta,
|
|
||||||
yellow,
|
|
||||||
white
|
|
||||||
// maybe add transparency?
|
|
||||||
};
|
|
||||||
|
|
||||||
// The tile format DF uses internally
|
|
||||||
struct df_screentile
|
|
||||||
{
|
|
||||||
uint8_t symbol;
|
|
||||||
uint8_t foreground; ///< df_color
|
|
||||||
uint8_t background; ///< df_color
|
|
||||||
uint8_t bright;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// our silly painter things and window things follow.
|
|
||||||
class df_window;
|
|
||||||
struct df_tilebuf
|
|
||||||
{
|
|
||||||
df_screentile * data;
|
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
};
|
|
||||||
|
|
||||||
DFHACK_EXPORT df_screentile *getScreenBuffer();
|
|
||||||
|
|
||||||
class DFHACK_EXPORT painter
|
|
||||||
{
|
|
||||||
friend class df_window;
|
|
||||||
public:
|
|
||||||
df_screentile* get(unsigned int x, unsigned int y)
|
|
||||||
{
|
|
||||||
if(x >= width || y >= height)
|
|
||||||
return 0;
|
|
||||||
return &buffer[x*height + y];
|
|
||||||
};
|
|
||||||
bool set(unsigned int x, unsigned int y, df_screentile tile )
|
|
||||||
{
|
|
||||||
if(x >= width || y >= height)
|
|
||||||
return false;
|
|
||||||
buffer[x*height + y] = tile;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
df_color foreground (df_color change = (df_color) -1)
|
|
||||||
{
|
|
||||||
if(change != -1)
|
|
||||||
current_foreground = change;
|
|
||||||
return current_foreground;
|
|
||||||
}
|
|
||||||
df_color background (df_color change = (df_color) -1)
|
|
||||||
{
|
|
||||||
if(change != -1)
|
|
||||||
current_background = change;
|
|
||||||
return current_background;
|
|
||||||
}
|
|
||||||
void bright (bool change)
|
|
||||||
{
|
|
||||||
current_bright = change;
|
|
||||||
}
|
|
||||||
bool bright ()
|
|
||||||
{
|
|
||||||
return current_bright;
|
|
||||||
}
|
|
||||||
void printStr(std::string & str, bool wrap = false)
|
|
||||||
{
|
|
||||||
for ( auto iter = str.begin(); iter != str.end(); iter++)
|
|
||||||
{
|
|
||||||
auto elem = *iter;
|
|
||||||
if(cursor_y >= (int)height)
|
|
||||||
break;
|
|
||||||
if(wrap)
|
|
||||||
{
|
|
||||||
if(cursor_x >= (int)width)
|
|
||||||
cursor_x = wrap_column;
|
|
||||||
}
|
|
||||||
df_screentile & tile = buffer[cursor_x * height + cursor_y];
|
|
||||||
tile.symbol = elem;
|
|
||||||
tile.foreground = current_foreground;
|
|
||||||
tile.background = current_background;
|
|
||||||
tile.bright = current_bright;
|
|
||||||
cursor_x++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void set_wrap (int new_column)
|
|
||||||
{
|
|
||||||
wrap_column = new_column;
|
|
||||||
}
|
|
||||||
void gotoxy(unsigned int x, unsigned int y)
|
|
||||||
{
|
|
||||||
cursor_x = x;
|
|
||||||
cursor_y = y;
|
|
||||||
}
|
|
||||||
void reset()
|
|
||||||
{
|
|
||||||
cursor_x = 0;
|
|
||||||
cursor_y = 0;
|
|
||||||
current_background = black;
|
|
||||||
current_foreground = white;
|
|
||||||
current_bright = false;
|
|
||||||
wrap_column = 0;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
painter (df_window * orig, df_screentile * buf, unsigned int width, unsigned int height)
|
|
||||||
{
|
|
||||||
origin = orig;
|
|
||||||
this->width = width;
|
|
||||||
this->height = height;
|
|
||||||
this->buffer = buf;
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
df_window* origin;
|
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
df_screentile* buffer;
|
|
||||||
// current paint cursor position
|
|
||||||
int cursor_x;
|
|
||||||
int cursor_y;
|
|
||||||
int wrap_column;
|
|
||||||
// current foreground color
|
|
||||||
df_color current_foreground;
|
|
||||||
// current background color
|
|
||||||
df_color current_background;
|
|
||||||
// make bright?
|
|
||||||
bool current_bright;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DFHACK_EXPORT df_window
|
|
||||||
{
|
|
||||||
friend class painter;
|
|
||||||
public:
|
|
||||||
df_window(int x, int y, unsigned int width, unsigned int height);
|
|
||||||
virtual ~df_window();
|
|
||||||
virtual bool move (int left_, int top_, unsigned int width_, unsigned int height_) = 0;
|
|
||||||
virtual void paint () = 0;
|
|
||||||
virtual painter * lock();
|
|
||||||
bool unlock (painter * painter);
|
|
||||||
virtual bool addChild(df_window *);
|
|
||||||
virtual df_tilebuf getBuffer() = 0;
|
|
||||||
public:
|
|
||||||
df_screentile* buffer;
|
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
protected:
|
|
||||||
df_window * parent;
|
|
||||||
std::vector <df_window *> children;
|
|
||||||
int left;
|
|
||||||
int top;
|
|
||||||
// FIXME: FAKE
|
|
||||||
bool locked;
|
|
||||||
painter * current_painter;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DFHACK_EXPORT top_level_window : public df_window
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
top_level_window();
|
|
||||||
virtual bool move (int left_, int top_, unsigned int width_, unsigned int height_);
|
|
||||||
virtual void paint ();
|
|
||||||
virtual painter * lock();
|
|
||||||
virtual df_tilebuf getBuffer();
|
|
||||||
};
|
|
||||||
class DFHACK_EXPORT buffered_window : public df_window
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
buffered_window(int x, int y, unsigned int width, unsigned int height):df_window(x,y,width, height)
|
|
||||||
{
|
|
||||||
buffer = new df_screentile[width*height];
|
|
||||||
};
|
|
||||||
virtual ~buffered_window()
|
|
||||||
{
|
|
||||||
delete buffer;
|
|
||||||
}
|
|
||||||
virtual void blit_to_parent ()
|
|
||||||
{
|
|
||||||
df_tilebuf par = parent->getBuffer();
|
|
||||||
for(unsigned xi = 0; xi < width; xi++)
|
|
||||||
{
|
|
||||||
for(unsigned yi = 0; yi < height; yi++)
|
|
||||||
{
|
|
||||||
unsigned parx = left + xi;
|
|
||||||
unsigned pary = top + yi;
|
|
||||||
if(pary >= par.height) continue;
|
|
||||||
if(parx >= par.width) continue;
|
|
||||||
par.data[parx * par.height + pary] = buffer[xi * height + yi];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual df_tilebuf getBuffer()
|
|
||||||
{
|
|
||||||
df_tilebuf buf;
|
|
||||||
buf.data = buffer;
|
|
||||||
buf.width = width;
|
|
||||||
buf.height = height;
|
|
||||||
return buf;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
class DFHACK_EXPORT dfhack_dummy : public buffered_window
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
dfhack_dummy(int x, int y):buffered_window(x,y,6,1){};
|
|
||||||
virtual bool move (int left_, int top_, unsigned int width_, unsigned int height_)
|
|
||||||
{
|
|
||||||
top = top_;
|
|
||||||
left = left_;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
virtual void paint ()
|
|
||||||
{
|
|
||||||
painter * p = lock();
|
|
||||||
p->bright(true);
|
|
||||||
p->background(black);
|
|
||||||
p->foreground(white);
|
|
||||||
std::string dfhack = "DFHack";
|
|
||||||
p->printStr(dfhack);
|
|
||||||
blit_to_parent();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
https://github.com/peterix/dfhack
|
|
||||||
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any
|
|
||||||
damages arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any
|
|
||||||
purpose, including commercial applications, and to alter it and
|
|
||||||
redistribute it freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must
|
|
||||||
not claim that you wrote the original software. If you use this
|
|
||||||
software in a product, an acknowledgment in the product documentation
|
|
||||||
would be appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and
|
|
||||||
must not be misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "Internal.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "VersionInfo.h"
|
|
||||||
#include "MemAccess.h"
|
|
||||||
#include "Types.h"
|
|
||||||
#include "Core.h"
|
|
||||||
|
|
||||||
#include "modules/Engravings.h"
|
|
||||||
#include "df/world.h"
|
|
||||||
|
|
||||||
using namespace DFHack;
|
|
||||||
using df::global::world;
|
|
||||||
|
|
||||||
bool Engravings::isValid()
|
|
||||||
{
|
|
||||||
return (world != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t Engravings::getCount()
|
|
||||||
{
|
|
||||||
return world->engravings.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
df::engraving * Engravings::getEngraving(int index)
|
|
||||||
{
|
|
||||||
if (uint32_t(index) >= getCount())
|
|
||||||
return NULL;
|
|
||||||
return world->engravings[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Engravings::copyEngraving(const int32_t index, t_engraving &out)
|
|
||||||
{
|
|
||||||
if (uint32_t(index) >= getCount())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
out.origin = world->engravings[index];
|
|
||||||
|
|
||||||
out.artist = out.origin->artist;
|
|
||||||
out.masterpiece_event = out.origin->masterpiece_event;
|
|
||||||
out.skill_rating = out.origin->skill_rating;
|
|
||||||
out.pos = out.origin->pos;
|
|
||||||
out.flags = out.origin->flags;
|
|
||||||
out.tile = out.origin->tile;
|
|
||||||
out.art_id = out.origin->art_id;
|
|
||||||
out.art_subid = out.origin->art_subid;
|
|
||||||
out.quality = out.origin->quality;
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
www.sourceforge.net/projects/dfhack
|
|
||||||
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any
|
|
||||||
damages arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any
|
|
||||||
purpose, including commercial applications, and to alter it and
|
|
||||||
redistribute it freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must
|
|
||||||
not claim that you wrote the original software. If you use this
|
|
||||||
software in a product, an acknowledgment in the product documentation
|
|
||||||
would be appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and
|
|
||||||
must not be misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Internal.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "VersionInfo.h"
|
|
||||||
#include "Types.h"
|
|
||||||
#include "Error.h"
|
|
||||||
#include "MemAccess.h"
|
|
||||||
#include "MiscUtils.h"
|
|
||||||
#include "ModuleFactory.h"
|
|
||||||
#include "Core.h"
|
|
||||||
#include "modules/Notes.h"
|
|
||||||
#include <DataDefs.h>
|
|
||||||
#include "df/ui.h"
|
|
||||||
using namespace DFHack;
|
|
||||||
|
|
||||||
std::unique_ptr<Module> DFHack::createNotes()
|
|
||||||
{
|
|
||||||
return dts::make_unique<Notes>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: not even a wrapper now
|
|
||||||
Notes::Notes()
|
|
||||||
{
|
|
||||||
notes = (std::vector<t_note*>*) &df::global::ui->waypoints.points;
|
|
||||||
}
|
|
@ -1,118 +0,0 @@
|
|||||||
/*
|
|
||||||
https://github.com/peterix/dfhack
|
|
||||||
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any
|
|
||||||
damages arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any
|
|
||||||
purpose, including commercial applications, and to alter it and
|
|
||||||
redistribute it freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must
|
|
||||||
not claim that you wrote the original software. If you use this
|
|
||||||
software in a product, an acknowledgment in the product documentation
|
|
||||||
would be appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and
|
|
||||||
must not be misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Export.h"
|
|
||||||
#include "Module.h"
|
|
||||||
#include "BitArray.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "DataDefs.h"
|
|
||||||
#include "df/init.h"
|
|
||||||
#include "df/ui.h"
|
|
||||||
#include <df/graphic.h>
|
|
||||||
#include "modules/Windows.h"
|
|
||||||
|
|
||||||
using namespace DFHack;
|
|
||||||
using df::global::gps;
|
|
||||||
|
|
||||||
Windows::df_screentile *Windows::getScreenBuffer()
|
|
||||||
{
|
|
||||||
if (!gps) return NULL;
|
|
||||||
return (df_screentile *) gps->screen;
|
|
||||||
}
|
|
||||||
|
|
||||||
Windows::df_window::df_window(int x, int y, unsigned int width, unsigned int height)
|
|
||||||
:buffer(0), width(width), height(height), parent(0), left(x), top(y), current_painter(NULL)
|
|
||||||
{
|
|
||||||
buffer = 0;
|
|
||||||
};
|
|
||||||
Windows::df_window::~df_window()
|
|
||||||
{
|
|
||||||
for(auto iter = children.begin();iter != children.end();iter++)
|
|
||||||
{
|
|
||||||
delete *iter;
|
|
||||||
}
|
|
||||||
children.clear();
|
|
||||||
};
|
|
||||||
Windows::painter * Windows::df_window::lock()
|
|
||||||
{
|
|
||||||
locked = true;
|
|
||||||
current_painter = new Windows::painter(this,buffer,width, height);
|
|
||||||
return current_painter;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool Windows::df_window::addChild( df_window * child)
|
|
||||||
{
|
|
||||||
children.push_back(child);
|
|
||||||
child->parent = this;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Windows::df_window::unlock (painter * painter)
|
|
||||||
{
|
|
||||||
if(current_painter == painter)
|
|
||||||
{
|
|
||||||
delete current_painter;
|
|
||||||
current_painter = 0;
|
|
||||||
locked = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Windows::top_level_window::top_level_window() : df_window(0,0,gps ? gps->dimx : 80,gps ? gps->dimy : 25)
|
|
||||||
{
|
|
||||||
buffer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Windows::top_level_window::move (int left_, int top_, unsigned int width_, unsigned int height_)
|
|
||||||
{
|
|
||||||
width = width_;
|
|
||||||
height = height_;
|
|
||||||
// what if we are painting already? Is that possible?
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
Windows::painter * Windows::top_level_window::lock()
|
|
||||||
{
|
|
||||||
buffer = getScreenBuffer();
|
|
||||||
return df_window::lock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Windows::top_level_window::paint ()
|
|
||||||
{
|
|
||||||
for(auto iter = children.begin();iter != children.end();iter++)
|
|
||||||
{
|
|
||||||
(*iter)->paint();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Windows::df_tilebuf Windows::top_level_window::getBuffer()
|
|
||||||
{
|
|
||||||
df_tilebuf buf;
|
|
||||||
buf.data = getScreenBuffer();
|
|
||||||
buf.height = df::global::gps->dimy;
|
|
||||||
buf.width = df::global::gps->dimx;
|
|
||||||
return buf;
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
#include "Core.h"
|
|
||||||
#include <Console.h>
|
|
||||||
#include <Export.h>
|
|
||||||
#include <PluginManager.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <modules/Notes.h>
|
|
||||||
|
|
||||||
using std::vector;
|
|
||||||
using std::string;
|
|
||||||
using namespace DFHack;
|
|
||||||
|
|
||||||
command_result df_notes (color_ostream &out, vector <string> & parameters);
|
|
||||||
|
|
||||||
DFHACK_PLUGIN("notes");
|
|
||||||
|
|
||||||
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
|
|
||||||
{
|
|
||||||
commands.push_back(PluginCommand("dumpnotes",
|
|
||||||
"Dumps in-game notes",
|
|
||||||
df_notes));
|
|
||||||
return CR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
|
|
||||||
{
|
|
||||||
return CR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
command_result df_notes (color_ostream &con, vector <string> & parameters)
|
|
||||||
{
|
|
||||||
CoreSuspender suspend;
|
|
||||||
|
|
||||||
DFHack::Notes * note_mod = Core::getInstance().getNotes();
|
|
||||||
std::vector<t_note*>* note_list = note_mod->notes;
|
|
||||||
|
|
||||||
if (note_list == NULL)
|
|
||||||
{
|
|
||||||
con.printerr("Notes are not supported under this version of DF.\n");
|
|
||||||
return CR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (note_list->empty())
|
|
||||||
{
|
|
||||||
con << "There are no notes." << std::endl;
|
|
||||||
return CR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (size_t i = 0; i < note_list->size(); i++)
|
|
||||||
{
|
|
||||||
t_note* note = (*note_list)[i];
|
|
||||||
|
|
||||||
con.print("Note %p at: %d/%d/%d\n",note, note->x, note->y, note->z);
|
|
||||||
con.print("Note id: %d\n", note->id);
|
|
||||||
con.print("Note symbol: '%c'\n", note->symbol);
|
|
||||||
|
|
||||||
if (note->name.length() > 0)
|
|
||||||
con << "Note name: " << (note->name) << std::endl;
|
|
||||||
if (note->text.length() > 0)
|
|
||||||
con << "Note text: " << (note->text) << std::endl;
|
|
||||||
|
|
||||||
if (note->unk1 != 0)
|
|
||||||
con.print("unk1: %x\n", note->unk1);
|
|
||||||
if (note->unk2 != 0)
|
|
||||||
con.print("unk2: %x\n", note->unk2);
|
|
||||||
|
|
||||||
con << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CR_OK;
|
|
||||||
}
|
|
Loading…
Reference in New Issue