Remove Notes module

Only used in a devel plugin that prints notes, and can be easily replaced
with `ui.waypoints.points`
develop
lethosor 2022-05-28 16:55:20 -04:00
parent 0aa7ec877e
commit 8bb047fcc6
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
11 changed files with 2 additions and 598 deletions

@ -47,6 +47,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Documentation
## API
- Removed ``Notes`` module (C++-only). Access ``ui.waypoints.points`` directly instead.
- Removed ``Windows`` module (C++-only) - unused.
## Lua
- ``tile-material``: fix the order of declarations. The ``GetTileMat`` function now returns the material as intended (always returned nil before). Also changed the license info, with permission of the original author.

@ -138,7 +138,6 @@ set(MODULE_HEADERS
include/modules/MapCache.h
include/modules/Maps.h
include/modules/Materials.h
include/modules/Notes.h
include/modules/Once.h
include/modules/Persistence.h
include/modules/Random.h
@ -165,7 +164,6 @@ set(MODULE_SOURCES
modules/MapCache.cpp
modules/Maps.cpp
modules/Materials.cpp
modules/Notes.cpp
modules/Once.cpp
modules/Persistence.cpp
modules/Random.cpp
@ -173,7 +171,6 @@ set(MODULE_SOURCES
modules/Screen.cpp
modules/Translation.cpp
modules/Units.cpp
modules/Windows.cpp
modules/World.cpp
)

@ -54,7 +54,6 @@ using namespace std;
#include "modules/Gui.h"
#include "modules/World.h"
#include "modules/Graphic.h"
#include "modules/Windows.h"
#include "modules/Persistence.h"
#include "RemoteServer.h"
#include "RemoteTools.h"
@ -1564,7 +1563,6 @@ Core::Core() :
last_local_map_ptr = NULL;
last_pause_state = false;
top_viewscreen = NULL;
screen_window = NULL;
color_ostream::log_errors_to_stderr = true;
@ -1835,8 +1833,6 @@ bool Core::Init()
cerr << "Starting DF input capture thread.\n";
// set up hotkey capture
d->hotkeythread = std::thread(fHKthread, (void *) temp);
screen_window = new Windows::top_level_window();
screen_window->addChild(new Windows::dfhack_dummy(5,10));
started = true;
modstate = 0;
@ -1984,7 +1980,6 @@ int Core::TileUpdate()
{
if(!started)
return false;
screen_window->paint();
return true;
}
@ -2922,5 +2917,4 @@ TYPE * Core::get##TYPE() \
}
MODULE_GETTER(Materials);
MODULE_GETTER(Notes);
MODULE_GETTER(Graphic);

@ -58,7 +58,6 @@ namespace DFHack
class Process;
class Module;
class Materials;
class Notes;
struct VersionInfo;
class VersionInfoFactory;
class PluginManager;
@ -69,10 +68,6 @@ namespace DFHack
namespace Lua { namespace Core {
DFHACK_EXPORT void Reset(color_ostream &out, const char *where);
} }
namespace Windows
{
class df_window;
}
namespace Screen
{
@ -146,8 +141,6 @@ namespace DFHack
/// get the materials module
Materials * getMaterials();
/// get the notes module
Notes * getNotes();
/// get the graphic module
Graphic * getGraphic();
/// sets the current hotkey command
@ -193,7 +186,6 @@ namespace DFHack
std::unique_ptr<DFHack::Process> p;
std::shared_ptr<DFHack::VersionInfo> vinfo;
DFHack::Windows::df_window * screen_window;
static void print(const char *format, ...) Wformat(printf,1,2);
static void printerr(const char *format, ...) Wformat(printf,1,2);
@ -242,7 +234,6 @@ namespace DFHack
struct
{
Materials * pMaterials;
Notes * pNotes;
Graphic * pGraphic;
} s_mods;
std::vector<std::unique_ptr<Module>> allModules;

@ -33,7 +33,6 @@ namespace DFHack
{
class Module;
std::unique_ptr<Module> createMaterials();
std::unique_ptr<Module> createNotes();
std::unique_ptr<Module> createGraphic();
}
#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,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;
}

@ -13,7 +13,6 @@ dfhack_plugin(eventExample eventExample.cpp)
dfhack_plugin(frozen frozen.cpp)
dfhack_plugin(kittens kittens.cpp LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
dfhack_plugin(memview memview.cpp memutils.cpp LINK_LIBRARIES lua)
dfhack_plugin(notes notes.cpp)
dfhack_plugin(onceExample onceExample.cpp)
dfhack_plugin(renderer-msg renderer-msg.cpp)
dfhack_plugin(rprobe rprobe.cpp)

@ -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;
}