[GTK3] Add DMG color palettes
This commit is contained in:
parent
836cb024b5
commit
9b360ef292
11
gtk3/main.c
11
gtk3/main.c
@ -1569,6 +1569,13 @@ G_MODULE_EXPORT void on_display_border_changed(GtkWidget *w, gpointer user_data_
|
||||
border_mode_changed = true;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void on_monochrome_palette_changed(GtkWidget *w, gpointer user_data_gptr) {
|
||||
GtkComboBox *box = GTK_COMBO_BOX(w);
|
||||
config.monochrome_palette_id = (gchar *)gtk_combo_box_get_active_id(box);
|
||||
|
||||
GB_set_palette(&gb, get_monochrome_palette());
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void on_color_menubar_override_changed(GtkWidget *w, gpointer user_data_gptr) {
|
||||
config.menubar_override = (gchar *)gtk_combo_box_get_active_id(GTK_COMBO_BOX(w));
|
||||
}
|
||||
@ -1994,7 +2001,7 @@ static void vblank(GB_gameboy_t *gb) {
|
||||
if (border_mode_changed) {
|
||||
GB_set_border_mode(gb, get_display_border_mode());
|
||||
update_window_geometry();
|
||||
|
||||
|
||||
border_mode_changed = false;
|
||||
}
|
||||
|
||||
@ -2211,6 +2218,8 @@ static void reset(GuiData *gui_data) {
|
||||
GB_switch_model_and_reset(&gb, current_model);
|
||||
}
|
||||
|
||||
GB_set_palette(&gb, get_monochrome_palette());
|
||||
|
||||
gui_data->prev_model = get_model();
|
||||
|
||||
GtkRequisition minimum_size;
|
||||
|
@ -142,6 +142,7 @@ G_MODULE_EXPORT void on_cgb_model_changed(GtkWidget *w, gpointer user_data_gptr)
|
||||
G_MODULE_EXPORT void on_color_correction_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_frame_blending_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_display_border_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_monochrome_palette_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_color_menubar_override_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_dmg_model_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_graphic_filter_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
|
@ -555,6 +555,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<property name="margin_top">16</property>
|
||||
<property name="margin_bottom">16</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
@ -597,6 +598,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
@ -630,6 +632,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
@ -666,7 +669,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Display Border:</property>
|
||||
<property name="label" translatable="yes">Color palette for monochrome models:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -674,6 +677,39 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="monochrome_palette_selector">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">10</property>
|
||||
<items>
|
||||
<item id="greyscale" translatable="yes">Greyscale</item>
|
||||
<item id="lime" translatable="yes">Lime (Game Boy)</item>
|
||||
<item id="olive" translatable="yes">Olive (Pocket)</item>
|
||||
<item id="teal" translatable="yes">Teal (Light)</item>
|
||||
</items>
|
||||
<signal name="changed" handler="on_monochrome_palette_changed" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Display Border:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="display_border_selector">
|
||||
<property name="visible">True</property>
|
||||
@ -690,7 +726,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">7</property>
|
||||
<property name="position">9</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
@ -708,9 +744,10 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">8</property>
|
||||
<property name="position">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="aspect_ratio_toggle">
|
||||
<property name="label" translatable="yes">Keep Aspect Ratio</property>
|
||||
@ -725,9 +762,10 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">9</property>
|
||||
<property name="position">11</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkLabel" id="menubar_override_selector_label">
|
||||
<property name="can_focus">False</property>
|
||||
@ -736,7 +774,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">10</property>
|
||||
<property name="position">12</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@ -753,7 +791,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">11</property>
|
||||
<property name="position">13</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
@ -761,6 +799,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child type="tab">
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
|
@ -110,6 +110,7 @@ void on_preferences_realize(GtkWidget *w, gpointer builder_ptr) {
|
||||
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "color_correction_selector"), config.color_correction_id);
|
||||
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "frame_blending_selector"), config.frame_blending_mode);
|
||||
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "display_border_selector"), config.display_border_mode);
|
||||
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "monochrome_palette_selector"), config.monochrome_palette_id);
|
||||
gtk_toggle_button_set_active(builder_get(GTK_TOGGLE_BUTTON, "integer_scaling_toggle"), config.use_integer_scaling);
|
||||
gtk_toggle_button_set_active(builder_get(GTK_TOGGLE_BUTTON, "aspect_ratio_toggle"), config.keep_aspect_ratio);
|
||||
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "highpass_filter_selector"), config.high_pass_filter_id);
|
||||
@ -326,7 +327,7 @@ GB_border_mode_t get_display_border_mode(void) {
|
||||
}
|
||||
|
||||
// This should not happen
|
||||
g_warning("Unknown frame blending mode: %s\nFalling back to “Never”", config.display_border_mode);
|
||||
g_warning("Unknown SGB border mode: %s\nFalling back to “Never”", config.display_border_mode);
|
||||
default_value: return GB_BORDER_NEVER;
|
||||
}
|
||||
|
||||
@ -344,6 +345,44 @@ void set_display_border_mode(GB_border_mode_t mode) {
|
||||
}
|
||||
}
|
||||
|
||||
const GB_palette_t* get_monochrome_palette(void) {
|
||||
if (config.monochrome_palette_id == NULL) goto default_value;
|
||||
|
||||
if (g_strcmp0(config.monochrome_palette_id, "greyscale") == 0) {
|
||||
return &GB_PALETTE_GREY;
|
||||
}
|
||||
else if (g_strcmp0(config.monochrome_palette_id, "lime") == 0) {
|
||||
return &GB_PALETTE_DMG;
|
||||
}
|
||||
else if (g_strcmp0(config.monochrome_palette_id, "olive") == 0) {
|
||||
return &GB_PALETTE_MGB;
|
||||
}
|
||||
else if (g_strcmp0(config.monochrome_palette_id, "teal") == 0) {
|
||||
return &GB_PALETTE_GBL;
|
||||
}
|
||||
|
||||
// This should not happen
|
||||
g_warning("Unknown monochrome palette: %s\nFalling back to “Greyscale”", config.monochrome_palette_id);
|
||||
default_value: return &GB_PALETTE_GREY;
|
||||
}
|
||||
|
||||
void set_monochrome_palette(const GB_palette_t *mode) {
|
||||
g_message("%p | %p | %p | %p | %p", mode, &GB_PALETTE_GREY, &GB_PALETTE_DMG, &GB_PALETTE_MGB, &GB_PALETTE_GBL);
|
||||
|
||||
if (mode == &GB_PALETTE_GREY) {
|
||||
config.monochrome_palette_id = "greyscale";
|
||||
}
|
||||
else if (mode == &GB_PALETTE_DMG) {
|
||||
config.monochrome_palette_id = "lime";
|
||||
}
|
||||
else if (mode == &GB_PALETTE_MGB) {
|
||||
config.monochrome_palette_id = "olive";
|
||||
}
|
||||
else if (mode == &GB_PALETTE_GBL) {
|
||||
config.monochrome_palette_id = "teal";
|
||||
}
|
||||
}
|
||||
|
||||
GB_highpass_mode_t get_highpass_mode(void) {
|
||||
if (config.high_pass_filter_id == NULL) goto default_value;
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
EXPAND_GROUP_MEMBER(color_correction_id, string, "emulate_hardware") \
|
||||
EXPAND_GROUP_MEMBER(frame_blending_mode, string, "disabled") \
|
||||
EXPAND_GROUP_MEMBER(display_border_mode, string, "never") \
|
||||
EXPAND_GROUP_MEMBER(monochrome_palette_id, string, "greyscale") \
|
||||
EXPAND_GROUP_MEMBER(keep_aspect_ratio, boolean, true) \
|
||||
EXPAND_GROUP_MEMBER(use_integer_scaling, boolean, true) \
|
||||
EXPAND_GROUP_MEMBER(menubar_override, string, "auto") \
|
||||
@ -100,6 +101,9 @@ void set_display_border_mode(GB_border_mode_t);
|
||||
GB_highpass_mode_t get_highpass_mode(void);
|
||||
void set_highpass_mode(GB_highpass_mode_t);
|
||||
|
||||
const GB_palette_t* get_monochrome_palette(void);
|
||||
void set_monochrome_palette(const GB_palette_t*);
|
||||
|
||||
GB_model_t get_dmg_model(void);
|
||||
GB_model_t get_sgb_model(void);
|
||||
GB_model_t get_cgb_model(void);
|
||||
|
Loading…
Reference in New Issue
Block a user