Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skeleton] print out which viewscreen we're changing to #4366

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/Process-linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ string Process::doReadClassName (void * vptr)
char * typeinfo = Process::readPtr(((char *)vptr - sizeof(void*)));
char * typestring = Process::readPtr(typeinfo + sizeof(void*));
string raw = readCString(typestring);
size_t start = raw.find_first_of("abcdefghijklmnopqrstuvwxyz");// trim numbers
size_t start = raw.find_first_of("abcdefghijklmnopqrstuvwxyz");// trim numbers
size_t end = raw.length();
return raw.substr(start,end-start);
}
Expand Down
18 changes: 17 additions & 1 deletion plugins/examples/skeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@

#include "Core.h"
#include "Debug.h"
#include "MemAccess.h"
#include "PluginManager.h"

#include "modules/Gui.h"
#include "modules/Persistence.h"
#include "modules/Screen.h"
#include "modules/World.h"

using std::string;
Expand Down Expand Up @@ -115,8 +118,21 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
DEBUG(status,out).print("game state changed: SC_MAP_UNLOADED\n");
break;
case SC_VIEWSCREEN_CHANGED:
DEBUG(status,out).print("game state changed: SC_VIEWSCREEN_CHANGED\n");
{
auto vs = Gui::getCurViewscreen(true);
string name = Core::getInstance().p->readClassName(*(void**)vs);
if (name.starts_with("viewscreen_"))
name = name.substr(11, name.size()-11-2);
else if (dfhack_viewscreen::is_instance(vs)) {
auto fs = Gui::getFocusStrings(vs);
if (fs.size())
name = fs[0];
}

DEBUG(status,out).print("game state changed: SC_VIEWSCREEN_CHANGED (%s)\n",
name.c_str());
break;
}
case SC_CORE_INITIALIZED:
DEBUG(status,out).print("game state changed: SC_CORE_INITIALIZED\n");
break;
Expand Down
Loading