2019.09.25
This commit is contained in:
parent
9ee4fef27a
commit
fda8dcdb3d
|
@ -48,11 +48,11 @@ static const char about_text[] =
|
|||
|
||||
static const PreferencesWidget prefs_fps[] = {
|
||||
WidgetLabel ("<b>Frames per second</b>"),
|
||||
WidgetSpin ("Max. :", WidgetInt (CFGID, "max_fps"), {1, 480, 1, "fps"}),
|
||||
WidgetSpin ("Max. :", WidgetInt (CFGID, "max_fps"), {1, 960, 1, "fps"}),
|
||||
WidgetLabel ("<b>How often change effect</b>"),
|
||||
WidgetSpin ("Every", WidgetInt (CFGID, "effect_time"), {1, 32000, 10, "frames"}),
|
||||
WidgetSpin ("Every", WidgetInt (CFGID, "effect_time"), {1, 128000, 10, "frames"}),
|
||||
WidgetLabel ("<b>How often change colors</b>"),
|
||||
WidgetSpin ("Every", WidgetInt (CFGID, "palette_time"), {25, 2000, 5, "frames"}),
|
||||
WidgetSpin ("Every", WidgetInt (CFGID, "palette_time"), {25, 8000, 5, "frames"}),
|
||||
|
||||
WidgetLabel ("<b>Controls</b>"),
|
||||
WidgetLabel ("Up/Down:\tup/down main volume"),
|
||||
|
|
|
@ -121,6 +121,21 @@ static inline t_complex fct(t_complex a, guint32 n, gint32 p1, gint32 p2) /* p
|
|||
b.x *= fact;
|
||||
b.y *= fact;
|
||||
break;
|
||||
|
||||
case 7: //if there's 8 of them, this is the last one. it's indexed by 0.
|
||||
if (b.x>100)
|
||||
{
|
||||
b.x = b.y;
|
||||
b.y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
b.x++;
|
||||
b.y++;
|
||||
circle_size = b.y;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
b.x = (gfloat)0.0;
|
||||
b.y = (gfloat)0.0;
|
||||
|
|
|
@ -19,9 +19,11 @@
|
|||
#include <glib.h>
|
||||
#include "types.h"
|
||||
|
||||
#define NB_FCT 7
|
||||
#define PI 3.14159
|
||||
// how many sigfigs do we need here? #define PI 3.125
|
||||
// how many effects there are?
|
||||
#define NB_FCT 8
|
||||
|
||||
// as close as C++ gets in a single constant float
|
||||
#define PI 3.141592653589793
|
||||
|
||||
/*
|
||||
* Represents the interpollation information.
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#define VIDEO_FLAGS ((Uint32)(SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE))
|
||||
|
||||
|
||||
typedef struct sincos {
|
||||
gint32 i;
|
||||
gfloat *f;
|
||||
|
@ -96,18 +97,68 @@ static gboolean sdl_init()
|
|||
return FALSE;
|
||||
}
|
||||
SDL_SetWindowTitle(window, "Infinity");
|
||||
|
||||
|
||||
// this is eventually going to be our icon from https://wiki.libsdl.org/SDL_SetWindowIcon
|
||||
SDL_Surface *surface; // Declare an SDL_Surface to be filled in with pixel data from an image file
|
||||
Uint16 pixels[16*16] = { // ...or with raw pixel data:
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff
|
||||
};
|
||||
surface = SDL_CreateRGBSurfaceFrom(pixels,16,16,16,16*2,0x0f00,0x00f0,0x000f,0xf000);
|
||||
|
||||
// The icon is attached to the window pointer
|
||||
SDL_SetWindowIcon(window, surface);
|
||||
|
||||
// ...and the surface containing the icon pixel data is no longer required.
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
return allocate_screen_and_texture();
|
||||
}
|
||||
|
||||
static void generate_colors()
|
||||
{
|
||||
gint32 i, k;
|
||||
gfloat colors[NB_PALETTES][2][3] = { { { 1.0, 1.0, 1.0 }, { 1.0, 1.0, 1.0 } },
|
||||
{ { 2.0, 1.5, 0.0 }, { 0.0, 0.5, 2.0 } },
|
||||
{ { 0.0, 1.0, 2.0 }, { 0.0, 1.0, 0.0 } },
|
||||
{ { 0.0, 2.0, 1.0 }, { 0.0, 0.0, 1.0 } },
|
||||
{ { 2.0, 0.0, 0.0 }, { 0.0, 1.0, 1.0 } } };
|
||||
gfloat colors[NB_PALETTES][2][3] = { { { 1.0, 1.0, 1.0 }, { 1.0, 1.0, 1.0 } }, //white + white
|
||||
{ { 2.0, 1.5, 0.0 }, { 0.0, 0.5, 2.0 } }, //yellow + purple?
|
||||
{ { 0.0, 1.0, 2.0 }, { 0.0, 1.0, 0.0 } }, //yellow + green
|
||||
{ { 0.0, 2.0, 1.0 }, { 0.0, 0.0, 1.0 } }, //etc
|
||||
{ { 2.0, 0.0, 0.0 }, { 0.0, 1.0, 1.0 } },
|
||||
{ { 0.0, 2.0, 0.0 }, { 0.0, 0.0, 0.0 } }, //matrix green
|
||||
{ { 0.0, 1.0, 0.0 }, { 1.0, 0.0, 1.0 } }
|
||||
};
|
||||
|
||||
//define lookup table for defining colours?
|
||||
for (k = 0; k < NB_PALETTES; k++) {
|
||||
for (i = 0; i < 128; i++) {
|
||||
color_table[k][i].r = (Uint8)(colors[k][0][0] * i);
|
||||
|
@ -458,9 +509,16 @@ void display_toggle_fullscreen(void)
|
|||
SDL_ShowCursor(is_in_fullscreen());
|
||||
}
|
||||
|
||||
void display_exit_fullscreen_if_needed(void) {
|
||||
if (is_in_fullscreen())
|
||||
display_toggle_fullscreen();
|
||||
void set_windowdressing(int yesno)
|
||||
{
|
||||
SDL_SetWindowBordered(window,yesno);
|
||||
}
|
||||
|
||||
int display_exit_fullscreen_if_needed(void) {
|
||||
int was_it=is_in_fullscreen();
|
||||
if (was_it)
|
||||
display_toggle_fullscreen();
|
||||
return was_it;
|
||||
}
|
||||
|
||||
inline void display_save_effect(t_effect *effect)
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
#include "effects.h"
|
||||
#include "music-player.h"
|
||||
|
||||
#define NB_PALETTES 5
|
||||
/* number of palettes */
|
||||
#define NB_PALETTES 7
|
||||
|
||||
/*
|
||||
* Initializes the display related structures, including the SDL library.
|
||||
|
@ -82,8 +83,9 @@ void curve(t_effect *current_effect);
|
|||
*/
|
||||
void display_toggle_fullscreen(void);
|
||||
|
||||
void display_exit_fullscreen_if_needed(void);
|
||||
int display_exit_fullscreen_if_needed(void);
|
||||
|
||||
void set_windowdressing(int);
|
||||
void display_save_effect(t_effect *effect);
|
||||
void display_load_random_effect(t_effect *effect);
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ static t_num_effect t_last_effect;
|
|||
|
||||
static gboolean must_resize;
|
||||
static gboolean finished;
|
||||
static gboolean display_border;
|
||||
static gboolean resizing;
|
||||
G_LOCK_DEFINE_STATIC(resizing);
|
||||
static gboolean initializing = FALSE;
|
||||
|
@ -187,11 +188,14 @@ static void handle_window_event(SDL_Event *event) {
|
|||
case SDL_WINDOWEVENT_HIDDEN:
|
||||
visible = FALSE;
|
||||
break;
|
||||
/*case SDL_WINDOWEVENT_MOVED:
|
||||
SDL_Log("Window %d moved to %d,%d",
|
||||
#ifdef INFINITY_DEBUG
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
// SDL_Log
|
||||
g_message("Window %d moved to %d,%d",
|
||||
event->window.windowID, event->window.data1,
|
||||
event->window.data2);
|
||||
break;*/
|
||||
break;
|
||||
#endif
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
G_LOCK(resizing);
|
||||
resizing = TRUE;
|
||||
|
@ -264,8 +268,6 @@ static void check_events()
|
|||
player->next(); break;
|
||||
case SDLK_F11:
|
||||
display_toggle_fullscreen(); break;
|
||||
case SDLK_ESCAPE:
|
||||
display_exit_fullscreen_if_needed(); break;
|
||||
case SDLK_F12:
|
||||
if (t_last_color > 32) {
|
||||
t_last_color = 0;
|
||||
|
@ -283,6 +285,28 @@ static void check_events()
|
|||
g_message("Infinity %s interactive mode", interactive_mode ? "entered" : "left");
|
||||
break;
|
||||
#endif
|
||||
case SDLK_TAB:
|
||||
{
|
||||
#ifdef INFINITY_DEBUG
|
||||
g_message("tab detected...killing border! %d",display_border);
|
||||
#endif
|
||||
display_border=!display_border;
|
||||
set_windowdressing(display_border);
|
||||
break;
|
||||
}
|
||||
case SDLK_ESCAPE:
|
||||
// seems like a sensible thing to do on escape
|
||||
#ifdef INFINITY_DEBUG
|
||||
g_message("escape detected");
|
||||
#endif
|
||||
if (display_exit_fullscreen_if_needed()) break;
|
||||
//should probably exit fullscreen, if not then exit entirely
|
||||
#ifdef INFINITY_DEBUG
|
||||
g_message("...and exit needed");
|
||||
#endif
|
||||
player->disable_plugin();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue