summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 555a6c9)
raw | patch | inline | side by side (parent: 555a6c9)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 10 Apr 2020 07:19:18 +0000 (11:19 +0400) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 10 Apr 2020 07:19:18 +0000 (11:19 +0400) |
src/gl/render.c | patch | blob | history | |
src/menu.c | patch | blob | history | |
src/menu.h | patch | blob | history | |
src/render.h | patch | blob | history |
diff --git a/src/gl/render.c b/src/gl/render.c
index bfd379c146f84a8f4d63e06a717806b6053638b6..08182864a6120b651e46f92cd4d9713677bd212c 100644 (file)
--- a/src/gl/render.c
+++ b/src/gl/render.c
/* Render Specific */
int SCRW = 320; // public
int SCRH = 200; // public
-static int gamma;
-static int fullscreen;
static rgb playpal[256];
static byte bright[256];
static GLuint lastTexture;
Y_swap_buffers();
}
-void R_alloc (void) {
+static void R_alloc (void) {
char s[10];
int i, j, n;
logo("R_alloc: load graphics\n");
}
}
-void R_toggle_fullscreen (void) {
+static void R_fullscreen (int yes) {
R_cache_free(root, 0);
- Y_set_fullscreen(!Y_get_fullscreen());
- fullscreen = Y_get_fullscreen();
+ Y_set_fullscreen(yes);
Y_get_videomode(&SCRW, &SCRH);
root = R_cache_new();
assert(root);
R_reload_textures();
}
+static int R_video_menu_handler (new_msg_t *msg, const new_menu_t *m, void *data) {
+ intptr_t i = (intptr_t)data;
+ static int fullscreen;
+ switch (i) {
+ case -1:
+ switch (msg->type) {
+ case GM_ENTER: fullscreen = Y_get_fullscreen(); return 1;
+ }
+ break;
+ case 0:
+ switch (msg->type) {
+ case GM_SELECT: fullscreen = !fullscreen; return 1;
+ case GM_GETSTR: return GM_init_str(msg, fullscreen ? "Yes" : "No", 3);
+ }
+ break;
+ case 1:
+ switch (msg->type) {
+ case GM_SELECT: R_fullscreen(fullscreen); return 1;
+ }
+ }
+ return 0;
+}
+
+static const new_menu_t video_menu = {
+ GM_BIG, "Video", (void*)-1, &R_video_menu_handler,
+ {
+ { GM_BUTTON, "Fullscreen: ", (void*)0, &R_video_menu_handler, NULL },
+ { GM_BUTTON, "Apply", (void*)1, &R_video_menu_handler, NULL },
+ { 0, NULL, NULL, NULL, NULL } // end
+ }
+};
+
+const new_menu_t *R_menu (void) {
+ return &video_menu;
+}
+
void R_init (void) {
logo("R_init: intialize opengl render\n");
R_init_playpal();
- R_set_videomode(SCRW, SCRH, fullscreen);
+ R_set_videomode(SCRW, SCRH, 0);
}
void R_done (void) {
root = NULL;
}
-void R_setgamma (int g) {
- gamma = g < 0 ? 0 : (g > 4 ? 4 : g);
-}
-
-int R_getgamma (void) {
- return gamma;
-}
-
void R_get_name (int n, char s[8]) {
assert(n >= 0 && n < 256);
if (walp[n].res == -1) {
diff --git a/src/menu.c b/src/menu.c
index e80e43612c2911159f50070bd163bd2692d71993..f7ba78fe63d4fdf0eb09b48de01419aef82f105a 100644 (file)
--- a/src/menu.c
+++ b/src/menu.c
}
}
-static int GM_init_int (new_msg_t *msg, int i, int a, int b, int s) {
+int GM_init_int (new_msg_t *msg, int i, int a, int b, int s) {
assert(msg != NULL);
assert(a <= b);
assert(s >= 0);
return 1;
}
-static int GM_init_str (new_msg_t *msg, char *str, int maxlen) {
+int GM_init_str (new_msg_t *msg, char *str, int maxlen) {
assert(msg != NULL);
assert(str != NULL);
assert(maxlen >= 0);
return 0;
}
+static int GM_options_handler (new_msg_t *msg, const new_menu_t *m, void *data) {
+ switch (msg->type) {
+ case GM_SELECT: GM_push(R_menu()); return 1;
+ }
+ return 0;
+}
+
static int GM_exit_handler (new_msg_t *msg, const new_menu_t *m, void *data) {
switch (msg->type) {
case GM_ENTER:
}, options_menu = {
GM_BIG, "Options", NULL, NULL,
{
- //{ GM_BUTTON, "Video", NULL, NULL, NULL },
+ { GM_BUTTON, "Video", NULL, &GM_options_handler, NULL },
{ GM_BUTTON, "Sound", NULL, NULL, &sound_menu },
{ GM_BUTTON, "Music", NULL, NULL, &music_menu },
{ 0, NULL, NULL, NULL, NULL } // end
diff --git a/src/menu.h b/src/menu.h
index b0b292903565b2949b88a87f5eec6a6be84a9eb1..38a32055ea50a6a5599b6cd34f598a159096af02 100644 (file)
--- a/src/menu.h
+++ b/src/menu.h
extern short lastkey;
+int GM_init_int (new_msg_t *msg, int i, int a, int b, int s);
+int GM_init_str (new_msg_t *msg, char *str, int maxlen);
+
void GM_push (const new_menu_t *m);
void GM_pop (void);
void GM_popall (void);
diff --git a/src/render.h b/src/render.h
index 49040173a7521b8b04ec8e70f93966b7a4b487b2..1299929ec2325375fa8bc3779f11ab639d658758 100644 (file)
--- a/src/render.h
+++ b/src/render.h
#ifndef RENDER_H_INCLUDED
#define RENDER_H_INCLUDED
+#include "menu.h"
+
extern int SCRW, SCRH; // from vga.c
-void R_draw (void);
-void R_alloc (void);
+const new_menu_t *R_menu (void);
void R_init (void);
+void R_draw (void);
void R_done (void);
-void R_setgamma (int g);
-int R_getgamma (void);
-void R_toggle_fullscreen (void);
void R_set_videomode (int w, int h, int fullscreen);
void R_get_name (int n, char s[8]);