2011-06-16 15:53:39 -06:00
|
|
|
/*
|
|
|
|
https://github.com/peterix/dfhack
|
|
|
|
Copyright (c) 2009-2011 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.
|
|
|
|
*/
|
|
|
|
|
2011-04-10 05:12:28 -06:00
|
|
|
#pragma once
|
2010-04-04 16:48:19 -06:00
|
|
|
#ifndef CL_MOD_GUI
|
|
|
|
#define CL_MOD_GUI
|
|
|
|
|
2011-12-31 04:48:42 -07:00
|
|
|
#include "Export.h"
|
|
|
|
#include "Module.h"
|
|
|
|
#include "Virtual.h"
|
|
|
|
#include "BitArray.h"
|
2011-07-09 03:33:58 -06:00
|
|
|
#include <string>
|
2010-04-04 16:48:19 -06:00
|
|
|
|
2012-01-07 08:21:07 -07:00
|
|
|
namespace df {
|
|
|
|
struct viewscreen;
|
|
|
|
struct job;
|
|
|
|
};
|
|
|
|
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
|
|
|
* \defgroup grp_gui query DF's GUI state
|
|
|
|
* @ingroup grp_modules
|
|
|
|
*/
|
|
|
|
|
2010-04-04 16:48:19 -06:00
|
|
|
namespace DFHack
|
|
|
|
{
|
2012-01-07 08:21:07 -07:00
|
|
|
class Core;
|
|
|
|
|
|
|
|
bool workshop_job_hotkey(Core *c, df::viewscreen *top);
|
|
|
|
bool build_selector_hotkey(Core *c, df::viewscreen *top);
|
|
|
|
|
|
|
|
df::job *getSelectedWorkshopJob(Core *c, bool quiet = false);
|
|
|
|
|
2010-05-26 04:24:45 -06:00
|
|
|
class DFContextShared;
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
2011-07-31 19:31:52 -06:00
|
|
|
* A GUI screen
|
2011-03-18 04:09:26 -06:00
|
|
|
* \ingroup grp_gui
|
|
|
|
*/
|
2011-07-09 03:33:58 -06:00
|
|
|
struct t_viewscreen : public t_virtual
|
2011-03-18 04:09:26 -06:00
|
|
|
{
|
2011-07-09 03:33:58 -06:00
|
|
|
t_viewscreen * child;
|
|
|
|
t_viewscreen * parent;
|
|
|
|
char unk1; // varies
|
|
|
|
char unk2; // state?
|
2011-03-18 04:09:26 -06:00
|
|
|
};
|
2011-07-09 03:33:58 -06:00
|
|
|
/**
|
2011-07-31 19:31:52 -06:00
|
|
|
* Interface - wrapper for the GUI
|
2011-07-09 03:33:58 -06:00
|
|
|
* \ingroup grp_gui
|
|
|
|
*/
|
|
|
|
struct t_interface
|
|
|
|
{
|
|
|
|
int fps;
|
|
|
|
t_viewscreen view;
|
|
|
|
unsigned int flags; // ?
|
|
|
|
// more crud this way ...
|
|
|
|
};
|
2011-07-31 19:31:52 -06:00
|
|
|
enum graphics_flag
|
|
|
|
{
|
|
|
|
GRAPHICS_ENABLED = 0,
|
|
|
|
GRAPHICS_BLACKSPACE = 1,
|
|
|
|
GRAPHICS_PARTIAL_PRINT = 2,
|
|
|
|
GRAPHICS_TEXT = 11,
|
|
|
|
GRAPHICS_FIXED_SIZE = 13
|
|
|
|
};
|
|
|
|
enum media_flag
|
|
|
|
{
|
|
|
|
MEDIA_NO_SOUND,
|
|
|
|
MEDIA_NO_INTRO,
|
|
|
|
MEDIA_COMPRESS_WORLDS,
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* The init structure - basically DF settings
|
|
|
|
* \ingroup grp_gui
|
|
|
|
*/
|
|
|
|
struct t_init
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
BitArray <graphics_flag> flags;
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
WINDOWED_YES,
|
|
|
|
WINDOWED_NO,
|
|
|
|
WINDOWED_PROMPT
|
|
|
|
} windowed;
|
|
|
|
// screen size in tiles
|
|
|
|
int grid_x;
|
|
|
|
int grid_y;
|
|
|
|
// in pixels ?
|
|
|
|
int fullscreen_x;
|
|
|
|
int fullscreen_y;
|
|
|
|
int window_x;
|
|
|
|
int window_y;
|
|
|
|
char partial_print;
|
|
|
|
} graphics;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
BitArray <media_flag> flags;
|
|
|
|
int32_t volume;
|
|
|
|
} media;
|
|
|
|
// much more stuff follows
|
|
|
|
};
|
2011-03-18 04:09:26 -06:00
|
|
|
#define NUM_HOTKEYS 16
|
|
|
|
/**
|
2011-07-09 03:33:58 -06:00
|
|
|
* The hotkey structure
|
2011-03-18 04:09:26 -06:00
|
|
|
* \ingroup grp_gui
|
|
|
|
*/
|
|
|
|
struct t_hotkey
|
|
|
|
{
|
2011-06-14 22:09:24 -06:00
|
|
|
std::string name;
|
2011-03-18 04:09:26 -06:00
|
|
|
int16_t mode;
|
|
|
|
int32_t x;
|
|
|
|
int32_t y;
|
|
|
|
int32_t z;
|
|
|
|
};
|
2011-07-09 03:33:58 -06:00
|
|
|
typedef t_hotkey hotkey_array[NUM_HOTKEYS];
|
|
|
|
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
2011-07-09 03:33:58 -06:00
|
|
|
* One tile of the screen. Possibly outdated.
|
2011-03-18 04:09:26 -06:00
|
|
|
* \ingroup grp_gui
|
|
|
|
*/
|
|
|
|
struct t_screen
|
|
|
|
{
|
|
|
|
uint8_t symbol;
|
|
|
|
uint8_t foreground;
|
|
|
|
uint8_t background;
|
|
|
|
uint8_t bright;
|
|
|
|
uint8_t gtile;
|
|
|
|
uint8_t grayscale;
|
|
|
|
};
|
2011-07-09 03:33:58 -06:00
|
|
|
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
|
|
|
* The Gui module
|
|
|
|
* \ingroup grp_modules
|
|
|
|
* \ingroup grp_gui
|
|
|
|
*/
|
2010-06-24 23:11:26 -06:00
|
|
|
class DFHACK_EXPORT Gui: public Module
|
2010-04-04 16:48:19 -06:00
|
|
|
{
|
|
|
|
public:
|
2011-03-18 04:09:26 -06:00
|
|
|
|
2011-06-17 07:02:43 -06:00
|
|
|
Gui();
|
2010-04-04 16:48:19 -06:00
|
|
|
~Gui();
|
|
|
|
bool Start();
|
|
|
|
bool Finish();
|
2011-03-18 04:09:26 -06:00
|
|
|
/*
|
|
|
|
* Cursor and window coords
|
|
|
|
*/
|
|
|
|
bool getViewCoords (int32_t &x, int32_t &y, int32_t &z);
|
|
|
|
bool setViewCoords (const int32_t x, const int32_t y, const int32_t z);
|
|
|
|
|
|
|
|
bool getCursorCoords (int32_t &x, int32_t &y, int32_t &z);
|
|
|
|
bool setCursorCoords (const int32_t x, const int32_t y, const int32_t z);
|
2011-09-25 19:39:27 -06:00
|
|
|
|
|
|
|
bool getDesignationCoords (int32_t &x, int32_t &y, int32_t &z);
|
|
|
|
bool setDesignationCoords (const int32_t x, const int32_t y, const int32_t z);
|
|
|
|
|
|
|
|
bool getMousePos (int32_t & x, int32_t & y);
|
2011-07-09 03:33:58 -06:00
|
|
|
/*
|
|
|
|
* Gui screens
|
|
|
|
*/
|
|
|
|
/// handle to the interface object
|
2011-07-16 10:10:08 -06:00
|
|
|
t_interface * df_interface;
|
2011-07-09 03:33:58 -06:00
|
|
|
/// Get the current top-level view-screen
|
|
|
|
t_viewscreen * GetCurrentScreen();
|
|
|
|
/// The DF menu state (designation menu ect)
|
2011-07-16 10:10:08 -06:00
|
|
|
uint32_t * df_menu_state;
|
2011-07-09 03:33:58 -06:00
|
|
|
|
2011-03-18 04:09:26 -06:00
|
|
|
/*
|
|
|
|
* Hotkeys (DF's zoom locations)
|
|
|
|
*/
|
2011-06-14 22:09:24 -06:00
|
|
|
hotkey_array * hotkeys;
|
2011-07-31 19:31:52 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Game settings
|
|
|
|
*/
|
|
|
|
t_init * init;
|
2011-03-18 04:09:26 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Window size in tiles
|
|
|
|
*/
|
|
|
|
bool getWindowSize(int32_t & width, int32_t & height);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Screen tiles
|
|
|
|
*/
|
|
|
|
bool getScreenTiles(int32_t width, int32_t height, t_screen screen[]);
|
|
|
|
|
2010-04-04 16:48:19 -06:00
|
|
|
private:
|
|
|
|
struct Private;
|
|
|
|
Private *d;
|
|
|
|
};
|
|
|
|
}
|
2010-05-01 18:38:18 -06:00
|
|
|
#endif
|
|
|
|
|