GTK: Add a couple animated background splashes.

This commit is contained in:
Brandon Wright 2019-11-08 17:05:36 -06:00
parent ab4b9513f2
commit 19f7423f42
6 changed files with 46 additions and 21 deletions

View File

@ -382,7 +382,9 @@ srcs += [
'src/gtk_netplay_dialog.cpp', 'src/gtk_netplay_dialog.cpp',
'src/gtk_netplay_dialog.h', 'src/gtk_netplay_dialog.h',
'src/gtk_netplay.cpp', 'src/gtk_netplay.cpp',
'src/gtk_netplay.h' 'src/gtk_netplay.h',
'src/background_particles.cpp',
'src/background_particles.h'
] ]
libjma_srcs = [ libjma_srcs = [

View File

@ -44,7 +44,9 @@ enum {
SPLASH_IMAGE_SMTPE = 1, SPLASH_IMAGE_SMTPE = 1,
SPLASH_IMAGE_PATTERN = 2, SPLASH_IMAGE_PATTERN = 2,
SPLASH_IMAGE_BLUE = 3, SPLASH_IMAGE_BLUE = 3,
SPLASH_IMAGE_COMBO = 4 SPLASH_IMAGE_COMBO = 4,
SPLASH_IMAGE_STARFIELD = 5,
SPLASH_IMAGE_SNOW = 6
}; };
class Snes9xConfig class Snes9xConfig

View File

@ -7,16 +7,17 @@
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#include "gtk_2_3_compat.h" #include "gtk_2_3_compat.h"
#include "gtk_config.h"
#include "gtk_s9x.h" #include "gtk_s9x.h"
#include "gtk_control.h" #include "gtk_control.h"
#include "gtk_sound.h" #include "gtk_sound.h"
#include "gtk_display.h" #include "gtk_display.h"
#include "gtk_netplay.h" #include "gtk_netplay.h"
#include "statemanager.h" #include "statemanager.h"
#include "background_particles.h"
void S9xPostRomInit (); void S9xPostRomInit ();
static void S9xThrottle (); static void S9xThrottle (int);
static void S9xCheckPointerTimer (); static void S9xCheckPointerTimer ();
static gboolean S9xIdleFunc (gpointer data); static gboolean S9xIdleFunc (gpointer data);
static gboolean S9xPauseFunc (gpointer data); static gboolean S9xPauseFunc (gpointer data);
@ -28,6 +29,8 @@ StateManager state_manager;
gint64 frame_clock = -1; gint64 frame_clock = -1;
gint64 pointer_timestamp = -1; gint64 pointer_timestamp = -1;
Background::Particles particles(Background::Particles::Mode::Snow);
void S9xTerm (int signal) void S9xTerm (int signal)
{ {
S9xExit (); S9xExit ();
@ -39,9 +42,6 @@ int main (int argc, char *argv[])
gtk_init (&argc, &argv); gtk_init (&argc, &argv);
g_set_prgname ("snes9x-gtk");
g_set_application_name ("Snes9x");
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, SNES9XLOCALEDIR); bindtextdomain (GETTEXT_PACKAGE, SNES9XLOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@ -263,9 +263,6 @@ static gboolean S9xPauseFunc (gpointer data)
{ {
S9xProcessEvents (true); S9xProcessEvents (true);
if (!gui_config->rom_loaded)
return true;
if (!S9xNetplayPush ()) if (!S9xNetplayPush ())
{ {
S9xNetplayPop (); S9xNetplayPop ();
@ -292,12 +289,30 @@ static gboolean S9xPauseFunc (gpointer data)
return false; return false;
} }
return true; if (!gui_config->rom_loaded)
{
if (gui_config->splash_image >= SPLASH_IMAGE_STARFIELD)
{
if (gui_config->splash_image == SPLASH_IMAGE_STARFIELD)
particles.setmode(Background::Particles::Stars);
else
particles.setmode(Background::Particles::Snow);
S9xThrottle(THROTTLE_TIMER);
particles.advance();
particles.copyto(GFX.Screen, GFX.Pitch);
S9xDeinitUpdate(256, 224);
}
}
g_timeout_add(8, S9xPauseFunc, NULL);
return false;
} }
gboolean S9xIdleFunc (gpointer data) gboolean S9xIdleFunc (gpointer data)
{ {
if (Settings.Paused) if (Settings.Paused && gui_config->rom_loaded)
{ {
S9xSetSoundMute (gui_config->mute_sound); S9xSetSoundMute (gui_config->mute_sound);
S9xSoundStop (); S9xSoundStop ();
@ -310,7 +325,7 @@ gboolean S9xIdleFunc (gpointer data)
} }
/* Move to a timer-based function to use less CPU */ /* Move to a timer-based function to use less CPU */
g_timeout_add (100, S9xPauseFunc, NULL); g_timeout_add (8, S9xPauseFunc, NULL);
return false; return false;
} }
@ -324,7 +339,7 @@ gboolean S9xIdleFunc (gpointer data)
return true; return true;
} }
S9xThrottle (); S9xThrottle (Settings.SkipFrames);
if (!S9xNetplayPush ()) if (!S9xNetplayPush ())
{ {
@ -461,7 +476,7 @@ void S9xParseArg (char **argv, int &i, int argc)
} }
} }
static void S9xThrottle () static void S9xThrottle (int method)
{ {
gint64 now; gint64 now;
@ -508,15 +523,15 @@ static void S9xThrottle ()
frame_clock = now; frame_clock = now;
} }
if (Settings.SkipFrames == THROTTLE_SOUND_SYNC || if (method == THROTTLE_SOUND_SYNC ||
Settings.SkipFrames == THROTTLE_NONE) method == THROTTLE_NONE)
{ {
frame_clock = now; frame_clock = now;
IPPU.SkippedFrames = 0; IPPU.SkippedFrames = 0;
} }
else // THROTTLE_TIMER or THROTTLE_TIMER_FRAMESKIP else // THROTTLE_TIMER or THROTTLE_TIMER_FRAMESKIP
{ {
if (Settings.SkipFrames == THROTTLE_TIMER_FRAMESKIP) if (method == THROTTLE_TIMER_FRAMESKIP)
{ {
if (now - frame_clock > Settings.FrameTime) if (now - frame_clock > Settings.FrameTime)
{ {

View File

@ -787,7 +787,7 @@ Snes9xWindow::expose ()
config->window_height = get_height (); config->window_height = get_height ();
} }
if (is_paused () || NetPlay.Paused) if ((is_paused () || NetPlay.Paused) && (gui_config->splash_image < SPLASH_IMAGE_STARFIELD || gui_config->rom_loaded))
{ {
S9xDeinitUpdate (last_width, last_height); S9xDeinitUpdate (last_width, last_height);
} }

View File

@ -166,7 +166,7 @@ bool gtk_shader_parameters_dialog(GtkWindow *parent)
if (!params || params->size() == 0) if (!params || params->size() == 0)
return false; return false;
dialog = gtk_dialog_new_with_buttons(_("GLSL Shader Parameters"), dialog = gtk_dialog_new_with_buttons(_("Shader Parameters"),
parent, parent,
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
"gtk-cancel", "gtk-cancel",

View File

@ -823,6 +823,12 @@
<row> <row>
<col id="0" translatable="yes">Color bars and patterns</col> <col id="0" translatable="yes">Color bars and patterns</col>
</row> </row>
<row>
<col id="0" translatable="yes">Starfield</col>
</row>
<row>
<col id="0" translatable="yes">Snow</col>
</row>
</data> </data>
</object> </object>
<object class="GtkListStore" id="liststore1"> <object class="GtkListStore" id="liststore1">