mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 12:31:10 +00:00
start working on a gui lib with a Slider class. use the slider class for
the volume settings. doesn't /quite/ work properly yet
This commit is contained in:
parent
1068032f1b
commit
ec26083228
26 changed files with 213 additions and 55 deletions
|
@ -2230,6 +2230,7 @@ AC_OUTPUT(
|
|||
ruamoko/include/Makefile
|
||||
ruamoko/lib/Makefile
|
||||
ruamoko/game/Makefile
|
||||
ruamoko/gui/Makefile
|
||||
ruamoko/cl_menu/Makefile
|
||||
|
||||
doc/Makefile
|
||||
|
|
|
@ -1 +1 @@
|
|||
SUBDIRS= include lib game cl_menu
|
||||
SUBDIRS= include lib game gui cl_menu
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Point.h"
|
||||
#include "gui/Point.h"
|
||||
#include "draw.h"
|
||||
|
||||
@interface Frame : Object
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "Point.h"
|
||||
#include "Frame.h"
|
||||
#include "Array.h"
|
||||
|
||||
@class Point;
|
||||
|
||||
@interface HUDObject : Object
|
||||
{
|
||||
Point origin;
|
||||
|
|
|
@ -40,8 +40,8 @@ menu_src= \
|
|||
|
||||
menu_obj=$(addsuffix .qfo,$(basename $(menu_src)))
|
||||
|
||||
menu.dat$(GZ): $(menu_obj) $(QFCC_DEP) ../lib/libcsqc.a ../lib/libr.a
|
||||
$(QFCC) $(QCFLAGS) -p $(STRIP) -o menu.dat $(menu_obj) ../lib/libcsqc.a ../lib/libr.a
|
||||
menu.dat$(GZ): $(menu_obj) $(QFCC_DEP) ../lib/libcsqc.a ../lib/libr.a ../gui/libgui.a
|
||||
$(QFCC) $(QCFLAGS) -p $(STRIP) -o menu.dat $(menu_obj) ../gui/libgui.a ../lib/libcsqc.a ../lib/libr.a
|
||||
$(GZIP)
|
||||
|
||||
EXTRA_DIST= $(menu_src) \
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#ifndef __client_menu_h
|
||||
#define __client_menu_h
|
||||
|
||||
#include "InputLine.h"
|
||||
|
||||
@class InputLine;
|
||||
@extern InputLine input_active;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include "gib.h"
|
||||
#include "draw.h"
|
||||
#include "key.h"
|
||||
#include "InputLine.h"
|
||||
#include "Rect.h"
|
||||
#include "string.h"
|
||||
#include "cbuf.h"
|
||||
#include "options.h"
|
||||
|
@ -15,6 +13,9 @@
|
|||
#include "HUD.h"
|
||||
#include "client_menu.h"
|
||||
|
||||
#include "gui/InputLine.h"
|
||||
#include "gui/Rect.h"
|
||||
|
||||
//FIXME shouldn't need these
|
||||
entity self;
|
||||
.float nextthink;
|
||||
|
|
|
@ -32,11 +32,16 @@
|
|||
#include "draw.h"
|
||||
#include "cvar.h"
|
||||
#include "key.h"
|
||||
#include "InputLine.h"
|
||||
#include "Rect.h"
|
||||
#include "controls_o.h"
|
||||
#include "options_util.h"
|
||||
|
||||
#include "gui/InputLine.h"
|
||||
#include "gui/Rect.h"
|
||||
#include "gui/Slider.h"
|
||||
|
||||
Slider volume_slider;
|
||||
Slider bgmvolume_slider;
|
||||
|
||||
/*
|
||||
some definitions of border values for different things
|
||||
*/
|
||||
|
@ -196,15 +201,22 @@ MENU_video_options =
|
|||
integer (string text, integer key)
|
||||
CB_audio_options =
|
||||
{
|
||||
local float volume;
|
||||
local float volume;
|
||||
local Slider slider;
|
||||
|
||||
if(!(key == QFK_RIGHT || key == QFK_LEFT )) {
|
||||
return 0;
|
||||
}
|
||||
if (text == "volume")
|
||||
slider = volume_slider;
|
||||
else
|
||||
slider = bgmvolume_slider;
|
||||
|
||||
volume = cvar (text);
|
||||
volume = min_max_cnt (MIN_VOLUME, MAX_VOLUME, VOLUME_STEP, volume,
|
||||
(key == QFK_RIGHT) && (key != QFK_LEFT));
|
||||
cvar_set (text, ftos (volume));
|
||||
[slider setIndex: to_percentage (MIN_VOLUME, MAX_VOLUME, volume)];
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
@ -227,13 +239,13 @@ DRAW_audio_options =
|
|||
bar_pad = y + 50;
|
||||
|
||||
Draw_String (x + 70, bar_pad + 10, "Volume:");
|
||||
draw_perc_bar (x + 126, bar_pad + 10, 15,
|
||||
to_percentage (MIN_VOLUME, MAX_VOLUME, cvar("volume")) );
|
||||
[volume_slider setBasePos:x y:y];
|
||||
[volume_slider draw];
|
||||
Draw_String (x + 126 + (15 + 4)*8 , bar_pad + 10, ftos(cvar("volume")));
|
||||
|
||||
Draw_String (x + 70, bar_pad + 18, "Music :");
|
||||
draw_perc_bar (x + 126, bar_pad + 18, 15,
|
||||
to_percentage (MIN_VOLUME, MAX_VOLUME, cvar("bgmvolume")) );
|
||||
[bgmvolume_slider setBasePos:x y:y];
|
||||
[bgmvolume_slider draw];
|
||||
Draw_String (x + 126 + (15 + 4)*8 , bar_pad + 18, ftos(cvar("bgmvolume")));
|
||||
|
||||
opt_cursor (x + 62, y + (Menu_GetIndex() * 10) + 60);
|
||||
|
@ -249,10 +261,21 @@ void ()
|
|||
MENU_audio_options =
|
||||
{
|
||||
local integer bar_pad;
|
||||
local Rect rect;
|
||||
|
||||
Menu_Begin (54, 60, "Audio");
|
||||
Menu_FadeScreen (1);
|
||||
Menu_Draw (DRAW_audio_options);
|
||||
|
||||
rect = [[Rect alloc] initWithComponents:126 :60 :15 * 8 :8];
|
||||
volume_slider = [[Slider alloc] initWithBounds:rect size:100];
|
||||
[volume_slider setIndex: to_percentage (MIN_VOLUME, MAX_VOLUME,
|
||||
cvar("volume"))];
|
||||
rect.origin.y += 8;
|
||||
bgmvolume_slider = [[Slider alloc] initWithBounds:rect size:100];
|
||||
[bgmvolume_slider setIndex: to_percentage (MIN_VOLUME, MAX_VOLUME,
|
||||
cvar("bgmvolume"))];
|
||||
[rect dealloc];
|
||||
|
||||
bar_pad = 0;
|
||||
Menu_Item (54, bar_pad + 10, "volume", CB_audio_options, 1);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include "menu.h"
|
||||
#include "draw.h"
|
||||
#include "InputLine.h"
|
||||
#include "Rect.h"
|
||||
#include "options_util.h"
|
||||
#include "controls_o.h"
|
||||
#include "client_menu.h"
|
||||
|
||||
#include "gui/InputLine.h"
|
||||
#include "gui/Rect.h"
|
||||
|
||||
integer (integer x, integer y) servlist_favorates_draw =
|
||||
{
|
||||
Draw_Pic (x + 16, y + 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
|
||||
|
|
9
ruamoko/gui/.gitignore
vendored
Normal file
9
ruamoko/gui/.gitignore
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
*.d
|
||||
*.dat
|
||||
*.pak
|
||||
*.qfo
|
||||
*.sym
|
||||
.deps
|
||||
.vimrc
|
||||
Makefile
|
||||
Makefile.in
|
|
@ -1,6 +1,5 @@
|
|||
#include "InputLine.h"
|
||||
|
||||
#include "Rect.h"
|
||||
#include "gui/InputLine.h"
|
||||
#include "gui/Rect.h"
|
||||
|
||||
inputline_t (integer lines, integer size, integer prompt) InputLine_Create = #0;
|
||||
void (inputline_t il, void [] data) InputLine_SetUserData = #0;
|
33
ruamoko/gui/Makefile.am
Normal file
33
ruamoko/gui/Makefile.am
Normal file
|
@ -0,0 +1,33 @@
|
|||
AUTOMAKE_OPTIONS= foreign
|
||||
|
||||
libdir=$(prefix)/lib/ruamoko
|
||||
|
||||
QFCC=$(top_builddir)/tools/qfcc/source/qfcc$(EXEEXT)
|
||||
QCFLAGS=-qq -g -Werror
|
||||
QCPPFLAGS=$(INCLUDES)
|
||||
PAK=$(top_builddir)/tools/pak/pak$(EXEEXT)
|
||||
RANLIB=touch
|
||||
|
||||
INCLUDES= -I$(top_srcdir)/ruamoko/include -I$(top_srcdir)/include
|
||||
|
||||
gui_libs=libgui.a
|
||||
if BUILD_RUAMOKO
|
||||
libs=$(gui_libs)
|
||||
else
|
||||
libs=
|
||||
endif
|
||||
|
||||
lib_LIBRARIES= $(libs)
|
||||
EXTRA_LIBRARIES= $(gui_libs)
|
||||
|
||||
%.qfo: %.r
|
||||
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -c -o $@ $<
|
||||
|
||||
%.o: %.r
|
||||
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -c -o $@ $<
|
||||
|
||||
libgui_a_SOURCES= \
|
||||
InputLine.r Point.r Rect.r Size.r Slider.r View.r
|
||||
libgui_a_AR= $(PAK) -cf
|
||||
|
||||
CLEANFILES= *.qfo *.o
|
|
@ -1,4 +1,4 @@
|
|||
#include "Point.h"
|
||||
#include "gui/Point.h"
|
||||
|
||||
@implementation Point
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#include "Object.h"
|
||||
#include "Point.h"
|
||||
#include "Size.h"
|
||||
#include "Rect.h"
|
||||
#include "gui/Point.h"
|
||||
#include "gui/Size.h"
|
||||
#include "gui/Rect.h"
|
||||
|
||||
@implementation Rect
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "Size.h"
|
||||
#include "gui/Size.h"
|
||||
|
||||
@implementation Size
|
||||
|
47
ruamoko/gui/Slider.r
Normal file
47
ruamoko/gui/Slider.r
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include "draw.h"
|
||||
|
||||
#include "gui/Slider.h"
|
||||
#include "gui/Rect.h"
|
||||
|
||||
@implementation Slider
|
||||
|
||||
- (id) initWithBounds: (Rect)aRect size: (integer) aSize
|
||||
{
|
||||
self = [super initWithBounds:aRect];
|
||||
dir = ylen > xlen;
|
||||
size = aSize;
|
||||
index = 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setIndex: (integer) ind
|
||||
{
|
||||
index = ind;
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
if (index > size)
|
||||
index = size;
|
||||
}
|
||||
|
||||
- (void) draw
|
||||
{
|
||||
local integer pos, x, y;
|
||||
|
||||
if (dir) {
|
||||
pos = index * ylen / size;
|
||||
Draw_Character (xabs, yabs, 1);
|
||||
for (y = 8; y < ylen - 8; y += 8)
|
||||
Draw_Character (xabs, yabs + y, 2);
|
||||
Draw_Character (xabs, yabs + y, 3);
|
||||
Draw_Character (xabs, yabs + pos, 131);
|
||||
} else {
|
||||
pos = index * xlen / size;
|
||||
Draw_Character (xabs, yabs, 128);
|
||||
for (x = 8; x < xlen - 8; x += 8)
|
||||
Draw_Character (xabs + x, yabs, 129);
|
||||
Draw_Character (xabs + x, yabs, 130);
|
||||
Draw_Character (xabs + pos, yabs, 131);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
39
ruamoko/gui/View.r
Normal file
39
ruamoko/gui/View.r
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include "gui/Size.h"
|
||||
#include "gui/Point.h"
|
||||
#include "gui/Rect.h"
|
||||
#include "gui/View.h"
|
||||
|
||||
@implementation View
|
||||
|
||||
- (id) initWithComponents: (integer)x : (integer)y : (integer)w : (integer)h
|
||||
{
|
||||
xpos = xabs = x;
|
||||
ypos = yabs = y;
|
||||
xlen = w;
|
||||
ylen = y;
|
||||
parent = NIL;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithOrigin: (Point)anOrigin size: (Size)aSize
|
||||
{
|
||||
return [self initWithComponents:anOrigin.x :anOrigin.y
|
||||
:aSize.width :aSize.height];
|
||||
}
|
||||
|
||||
- (id) initWithBounds: (Rect)aRect
|
||||
{
|
||||
return [self initWithOrigin:aRect.origin size:aRect.size];
|
||||
}
|
||||
|
||||
- (void) setBasePos: (integer) x y: (integer) y
|
||||
{
|
||||
xabs = xpos + x;
|
||||
yabs = ypos + y;
|
||||
}
|
||||
|
||||
-(void) draw
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
|
@ -8,5 +8,6 @@ include_HEADERS= \
|
|||
draw.h key.h \
|
||||
\
|
||||
cbuf.h cmd.h cvar.h file.h gib.h hash.h plist.h \
|
||||
Object.h AutoreleasePool.h Array.h Entity.h List.h ListNode.h \
|
||||
InputLine.h Point.h Rect.h Size.h Stack.h
|
||||
Object.h AutoreleasePool.h Array.h Entity.h List.h ListNode.h Stack.h \
|
||||
\
|
||||
gui/InputLine.h gui/Point.h gui/Rect.h gui/Size.h gui/View.h
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#define __ruamoko_Rect_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "Point.h"
|
||||
#include "Size.h"
|
||||
#include "gui/Point.h"
|
||||
#include "gui/Size.h"
|
||||
|
||||
@interface Rect: Object
|
||||
{
|
19
ruamoko/include/gui/Slider.h
Normal file
19
ruamoko/include/gui/Slider.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef __ruamoko_Slider_h
|
||||
#define __ruamoko_Slider_h
|
||||
|
||||
#include "View.h"
|
||||
|
||||
@interface Slider: View
|
||||
{
|
||||
integer index;
|
||||
integer size;
|
||||
integer dir;
|
||||
}
|
||||
|
||||
- (id) initWithBounds: (Rect)aRect size: (integer) aSize;
|
||||
- (void) setIndex: (integer) ind;
|
||||
- (void) draw;
|
||||
|
||||
@end
|
||||
|
||||
#endif //__ruamoko_Slider_h
|
|
@ -2,8 +2,10 @@
|
|||
#define __ruamoko_View_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "Point.h"
|
||||
#include "Size.h"
|
||||
|
||||
@class Point;
|
||||
@class Size;
|
||||
@class Rect;
|
||||
|
||||
@interface View: Object
|
||||
{
|
||||
|
@ -15,7 +17,10 @@
|
|||
}
|
||||
|
||||
- (id) initWithComponents: (integer)x : (integer)y : (integer)w : (integer)h;
|
||||
- (id) initWithOrigin: (Point)anOrigin size: (Size)aSize;
|
||||
- (id) initWithBounds: (Rect)aRect;
|
||||
- (void) setBasePos: (integer) x y: (integer) y;
|
||||
- (void) draw;
|
||||
@end
|
||||
|
||||
#endif //__ruamoko_Rect_h
|
||||
#endif //__ruamoko_View_h
|
|
@ -28,8 +28,7 @@ EXTRA_LIBRARIES= $(ruamoko_libs)
|
|||
|
||||
libr_a_SOURCES=\
|
||||
cbuf.r cmd.r cvar.r file.r qfile.r string.r \
|
||||
Object.r AutoreleasePool.r Array.r Entity.r List.r ListNode.r Point.r \
|
||||
Rect.r Size.r Stack.r
|
||||
Object.r AutoreleasePool.r Array.r Entity.r List.r ListNode.r Stack.r
|
||||
libr_a_AR=$(PAK) -cf
|
||||
|
||||
libqw_a_SOURCES=\
|
||||
|
@ -44,7 +43,7 @@ libnq_a_SOURCES=\
|
|||
libnq_a_AR=$(PAK) -cf
|
||||
|
||||
libcsqc_a_SOURCES= \
|
||||
draw.r gib.r InputLine.r key.r system.r
|
||||
draw.r gib.r key.r system.r
|
||||
libcsqc_a_AR= $(PAK) -cf
|
||||
|
||||
CLEANFILES= *.qfo *.o
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
#include "View.h"
|
||||
|
||||
@implementation View
|
||||
|
||||
-(id) initWithComponents: (integer)x : (integer)y : (integer)w : (integer)h
|
||||
{
|
||||
xpos = xabs = x;
|
||||
ypos = yabs = y;
|
||||
xlen = w;
|
||||
ylen = y;
|
||||
parent = NIL;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) draw
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in a new issue