⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui.hpp

📁 SNES game emulator. C and asm files.
💻 HPP
字号:
/*	GUI.HPP
	Lots of GUI stuff.
*/

#ifndef _GUI_HPP
#define _GUI_HPP

	// Types of controls
#define TEXT 1
#define BUTTON 2
#define SLIDER 3
#define KEYCODE 4
#define CHECK 5
#define RADIO 6
#define INPUT 7
#define LISTBOX 8

	// GUI settings
extern struct colorset set;
extern byte background;
extern boolean escquits;
extern boolean confirmexit;
extern int mouseptr; // mouse pointer
extern boolean returntogame;
extern boolean quitemu;
extern boolean doubleclick;

extern int guiframes, guistarttime, guifps;

extern int messagecolor;
extern boolean messageoutline;

#define NUMMAINCONTROLS 11
#define NUMSAVELOADCONTROLS 23
#define NUMSTARTUPCONTROLS 10
#define NUMINGAMECONTROLS 17
#define NUMJOYPADCONTROLS 18
#define NUMGUISETTINGCONTROLS 18
#define NUMCHEATCODECONTROLS 17
#define NUMLOADCONTROLS 9
#define NUMMESSAGEBOXCONTROLS 3
#define NUMWINDOWS 9

	// windows and controls
extern struct guiwindow mainwindow;
extern struct guiwindow saveloadwindow;
extern struct guiwindow startupwindow;
extern struct guiwindow ingamewindow;
extern struct guiwindow joypadwindow;
extern struct guiwindow guisettingwindow;
extern struct guiwindow cheatcodewindow;
extern struct guiwindow loadwindow;
extern struct guiwindow messagewindow;
extern struct guicontrol maincontrols [NUMMAINCONTROLS];
extern struct guicontrol saveloadcontrols [NUMSAVELOADCONTROLS];
extern struct guicontrol startupoptions [NUMSTARTUPCONTROLS];
extern struct guicontrol ingameoptions [NUMINGAMECONTROLS];
extern struct guicontrol joypadcontrols [NUMJOYPADCONTROLS];
extern struct guicontrol guisettingcontrols [NUMGUISETTINGCONTROLS];
extern struct guiwindow *win [NUMWINDOWS];

extern struct guicontrol mbc [NUMMESSAGEBOXCONTROLS];

struct guicontrol {
	byte type;
	char *text [6];
	byte x [6], y [6], w, h;
	byte number;
		// In single-controls, only x[0], y[0], w and h are used.
		// Number is the number of controls in the set.
		// w and h are only used for buttons, sliders and keycodes.
	short min, max;
	byte interval;
		// min, max and interval are used only for slider controls.
	boolean largefont; // false=use 8pt font true=use 10pt font
		// state of control.

		// vars indicating current state of control:
	boolean disabled, hidden;
		// Control is unaccessable if either of these is true.
	short choice;
		// In a checkbox control set, bit 0=control 0 state, bit 1=control 1 state etc.
		// In a radio control set, which control has the dot.
		// In a slider, where the slider is.
		// In a keycode control, what the keycode is.
		// In an input control, the position of the cursor.
	signed char focus; // In a multicontrol, which one has the focus
	boolean clicked;
		// Whether the mouse is depressed on the control.
};

struct listboxinfo { // One of these structures is placed in the control's text[4].
	int entries;
	boolean shaft, upclicked, downclicked; // Whether there is a shaft
	int offset, lines, shaftht, sboxht, sboxpos; // lines is the number of lines that fit in the list box viewing area
	struct listboxcolumn {
		int xoffset;
		int totalmem, usedmem;
	} col [4];
};

struct guiwindow {
	char title [64];
	struct guicontrol *c;
	void (*windowproc) (int msg, int cnum, int v1);
	int numcontrols;
	boolean tabonly; // If true, only TAB can be used to change focus with the keyboard,
		// up/down moves slider or selects check or radio button like left and right.
	int x, y, w, h; // Position and size.
	int skip; // if not 0, pixels get skipped in drawing window and borders are not drawn.
	int focus; // Which control number/set has the keyboard focus.
	boolean xclicked; // Whether the X is clicked down
	signed char zorder; // 0=highest 127=lowest (<=-1:invisible and unselectable)
};

struct colorset {
	byte window, text, control, choice;
	byte button, buttontext, title, titletext;
	byte focus, flash;
};

void initgui ();
void drawwindow (struct guiwindow &w, boolean active = true);
void drawcontrol (struct guicontrol &c, int wx, int wy, boolean focus = false, int skip = 0);
void drawmouse ();
	// ^ Drawing functions
void initlistbox (struct guicontrol &c);
void uninitlistbox (struct guicontrol &c);
void addlistentry (struct guicontrol &c, int where);
void removelistentry (struct guicontrol &c, int where);
void changelistentry (struct guicontrol &c, int where, int col, char *s);
int findlistentry (struct guicontrol &c, int where, int col);
	// ^ List box editing functions
int whichcontrol (int wnum, int x, int y, int *subctl = NULL);
int whichcontrol (struct guiwindow *w, int x, int y, int *subctl = NULL);
int whichwindow (int x, int y);
void getcontrolsize (struct guicontrol *c, int subctl, int &w, int &h);
int activewindow ();
boolean mouseison (struct guiwindow &w, struct guicontrol &c, int subctl = 0);
	// ^ Various helper functions
void backupfocus (struct guiwindow *w);
void advancefocus (struct guiwindow *w);
void advancebadfocus (struct guiwindow *w);
inline void sendmessage (int wnum, int msg, int cnum=0, int v1=0)
	{ win[wnum]->windowproc (msg, cnum, v1); }
inline void sendmessage (struct guiwindow *w, int msg, int cnum=0, int v1=0)
	{ w->windowproc (msg, cnum, v1); }
void showwindow (struct guiwindow *w);
void killwindow (struct guiwindow *w);
inline void killwindow (int num)
	{ killwindow (win[num]); }
inline void showwindow (int num)
	{ showwindow (win[num]); }
void defwindowproc (struct guiwindow &w, int msg, int cnum, int v1);
void showgui ();
void setguisettings ();
void addmessage (char *format, ...);
void showmessages ();
void messagebox (char *title, char *msg);
int rungui ();

#define GUIRETURN 1
#define GUIQUIT 0

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -