Add some basic GUI code
parent
4fee1465df
commit
0b3b95a79f
24
Makefile
24
Makefile
|
@ -30,6 +30,12 @@ define tgt_template =
|
|||
$(1)_BINARYS=$(3)
|
||||
endef
|
||||
|
||||
define exe_template =
|
||||
$(1)_SOURCES=$(SRC)/$(2)
|
||||
$(1)_OUTPUTS=$$($(1)_SOURCES:$(SRC)/%.c=$(BIN)/%.o)
|
||||
$(1)_BINARYS=$(3)
|
||||
endef
|
||||
|
||||
define lib_template =
|
||||
$(1)_SOURCES=$$(wildcard $(SRC)/$(2)*.c)
|
||||
$(1)_HEADERS=$$(wildcard $(SRC)/$(2)*.h)
|
||||
|
@ -40,7 +46,11 @@ endef
|
|||
$(eval $(call tgt_template,MAIN,main.c,$(CODEDEFS)/eikyo-main.bin))
|
||||
$(eval $(call tgt_template,MFED,mfed.c,$(CODEDEFS_MFED)/eikyo-mfed.bin))
|
||||
|
||||
$(eval $(call exe_template,STRH,strh.c,$(BIN)/strh))
|
||||
$(eval $(call exe_template,GOL5,golan5.c,$(BIN)/golan5))
|
||||
|
||||
$(eval $(call lib_template,GAME,g_,eikyo-game.bin))
|
||||
$(eval $(call lib_template,INTR,i_,eikyo-interface.bin))
|
||||
$(eval $(call lib_template,RNDR,r_,eikyo-render.bin))
|
||||
$(eval $(call lib_template,MISC,m_,eikyo-misc.bin))
|
||||
|
||||
|
@ -49,25 +59,23 @@ MISC_LIBOUTS=$(MISC_SOURCES:$(SRC)/%.c=$(BIN)/%.o)
|
|||
MAPS_SOURCES=$(wildcard $(MAPSRC)/*.gmf9)
|
||||
MAPS_OUTPUTS=$(MAPS_SOURCES:$(MAPSRC)/%.gmf9=$(MAPBIN)/%.gmf0)
|
||||
|
||||
GOL5_SOURCES=$(SRC)/golan5.c
|
||||
GOL5_OUTPUTS=$(GOL5_SOURCES:$(SRC)/%.c=$(BIN)/%.o)
|
||||
GOL5_BINARYS=$(BIN)/golan5
|
||||
|
||||
LIBC_OUTPUTS=$(IR)/libc.ir $(IR)/libGDCC.ir
|
||||
LIBC_BINARYS=$(CODEDEFS)/stdlib.bin
|
||||
|
||||
.PHONY: clean
|
||||
.SECONDARY: $(MISC_LIBOUTS)
|
||||
|
||||
all: $(FOLDERS) $(GAME_BINARYS) $(MAIN_BINARYS) $(MFED_BINARYS) $(MISC_BINARYS) $(RNDR_BINARYS) $(LIBC_BINARYS) $(MAPS_OUTPUTS)
|
||||
all: $(FOLDERS) $(GAME_BINARYS) $(INTR_BINARYS) $(MAIN_BINARYS) $(MFED_BINARYS) $(MISC_BINARYS) $(RNDR_BINARYS) $(LIBC_BINARYS) $(MAPS_OUTPUTS)
|
||||
|
||||
$(GAME_BINARYS): $(GAME_OUTPUTS)
|
||||
$(GOL5_BINARYS): $(GOL5_OUTPUTS)
|
||||
$(INTR_BINARYS): $(INTR_OUTPUTS)
|
||||
$(LIBC_BINARYS): $(LIBC_OUTPUTS)
|
||||
$(MAIN_BINARYS): $(MAIN_OUTPUTS)
|
||||
$(MFED_BINARYS): $(MFED_OUTPUTS)
|
||||
$(MISC_BINARYS): $(MISC_OUTPUTS)
|
||||
$(RNDR_BINARYS): $(RNDR_OUTPUTS)
|
||||
$(LIBC_BINARYS): $(LIBC_OUTPUTS)
|
||||
$(STRH_BINARYS): $(STRH_OUTPUTS)
|
||||
|
||||
$(FOLDERS):
|
||||
mkdir -p $@
|
||||
|
@ -87,8 +95,8 @@ $(BIN)/%.o: $(SRC)/%.c $(MISC_HEADERS)
|
|||
%.bin:
|
||||
$(GDCC_LD) $(GDCC_LFLAGS) -o $@ $^
|
||||
|
||||
$(IR)/%.ir: $(SRC)/%.c $(GAME_HEADERS) $(MISC_HEADERS) $(RNDR_HEADERS)
|
||||
$(GDCC_CC) $(GDCC_CFLAGS) -o $@ $<
|
||||
$(IR)/%.ir: $(SRC)/%.c $(GAME_HEADERS) $(INTR_HEADERS) $(MISC_HEADERS) $(RNDR_HEADERS) $(STRH_BINARYS)
|
||||
$(GDCC_CC) $(GDCC_CFLAGS) -DM_fileHash=$(shell bin/strh $<) -o $@ $<
|
||||
|
||||
$(LIBC_OUTPUTS):
|
||||
$(GDCC_MAKELIB) $(GDCC_CFLAGS) -o $@ $(basename $(@F))
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
// Copyright © 2017 Project Golan, all rights reserved.
|
||||
#include "i_gui.h"
|
||||
|
||||
#include "m_math.h"
|
||||
|
||||
// Static Functions ----------------------------------------------------------|
|
||||
|
||||
//
|
||||
// I_GUI_auto
|
||||
//
|
||||
static void I_GUI_auto(I_gictx *g, I_objid id, int xl, int yl, int xu, int yu)
|
||||
{
|
||||
if(M_AABBPoint(xl, yl, xu, yu, g->cr.x, g->cr.y)) {
|
||||
g->hot = id;
|
||||
if(g->lc) g->act = id;
|
||||
}
|
||||
}
|
||||
|
||||
// Extern Functions ----------------------------------------------------------|
|
||||
|
||||
//
|
||||
// I_GUI_Begin
|
||||
//
|
||||
void I_GUI_Begin(I_gictx *g)
|
||||
{
|
||||
g->hot = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// I_GUI_End
|
||||
//
|
||||
void I_GUI_End(I_gictx *g)
|
||||
{
|
||||
// Set last left/right clicks.
|
||||
g->llc = g->lc;
|
||||
g->lrc = g->rc;
|
||||
|
||||
if(!g->lc && !g->rc)
|
||||
g->act = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// I_GUI_ButtonFId
|
||||
//
|
||||
bool I_GUI_ButtonFId(I_gictx *g, I_objid id, int x, int y, char const *text)
|
||||
{
|
||||
int const xl = x , yl = y;
|
||||
int const xu = x + 90, yu = y + 30;
|
||||
|
||||
I_GUI_auto(g, id, xl, yl, xu, yu);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// EOF
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright © 2017 Project Golan, all rights reserved.
|
||||
#ifndef i_gui_h
|
||||
#define i_gui_h
|
||||
|
||||
#include "m_types.h"
|
||||
#include "i_ui.h"
|
||||
|
||||
#include <Doominati.h>
|
||||
|
||||
#define I_GUI_button(g, ...) I_GUI_ButtonFId(g, I_lineHash, __VA_ARGS__)
|
||||
|
||||
// Extern Functions ----------------------------------------------------------|
|
||||
|
||||
void I_GUI_Begin(struct I_gictx *g);
|
||||
void I_GUI_End (struct I_gictx *g);
|
||||
|
||||
// Types ---------------------------------------------------------------------|
|
||||
|
||||
typedef struct I_gictx
|
||||
{
|
||||
__prop begin {call: I_GUI_Begin(this)}
|
||||
__prop end {call: I_GUI_End (this)}
|
||||
|
||||
I_objid hot, act;
|
||||
|
||||
DGE_Point2I cr;
|
||||
|
||||
// TODO: make these a bitfield when david adds Bget_W translation
|
||||
bool lc, llc;
|
||||
bool rc, lrc;
|
||||
|
||||
bool open;
|
||||
} I_gictx;
|
||||
|
||||
// Types ---------------------------------------------------------------------|
|
||||
|
||||
bool I_GUI_ButtonFId(struct I_gictx *g, I_objid id, int x, int y, char const *text);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright © 2017 Project Golan, all rights reserved.
|
||||
#ifndef i_ui_h
|
||||
#define i_ui_h
|
||||
|
||||
#define I_lineHash (M_fileHash + __LINE__)
|
||||
|
||||
// Types ---------------------------------------------------------------------|
|
||||
|
||||
typedef unsigned I_objid;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright © 2017 Project Golan, all rights reserved.
|
||||
#include "m_math.h"
|
||||
|
||||
// Extern Functions ----------------------------------------------------------|
|
||||
|
||||
//
|
||||
// M_AABBPoint
|
||||
//
|
||||
bool M_AABBPoint(fixed xl, fixed yl, fixed xu, fixed yu, fixed xp, fixed yp)
|
||||
{
|
||||
return xp > xl && yp > yl && xp < xu && yp < yu;
|
||||
}
|
||||
|
||||
// EOF
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright © 2017 Project Golan, all rights reserved.
|
||||
#ifndef m_math_h
|
||||
#define m_math_h
|
||||
|
||||
#include "m_types.h"
|
||||
|
||||
// Extern Functions ----------------------------------------------------------|
|
||||
|
||||
bool M_AABBPoint(fixed xl, fixed yl, fixed xu, fixed yu, fixed xp, fixed yp);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright © 2017 Project Golan, all rights reserved.
|
||||
#include "m_str.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// Extern Functions ----------------------------------------------------------|
|
||||
|
||||
//
|
||||
// main
|
||||
//
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc) printf("%u\n", M_StrHash(argv[1]));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// EOF
|
Loading…
Reference in New Issue