Daniele Bartolini 9 лет назад
Родитель
Сommit
702ba536f3
2 измененных файлов с 311 добавлено и 214 удалено
  1. 60 0
      tools/level_editor/preferences_dialog.vala
  2. 251 214
      tools/ui/level_editor_preferences_dialog.ui

+ 60 - 0
tools/level_editor/preferences_dialog.vala

@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2012-2016 Daniele Bartolini and individual contributors.
+ * License: https://github.com/taylor001/crown/blob/master/LICENSE-GPLv2
+ */
+
+using Gtk;
+
+namespace Crown
+{
+	[GtkTemplate (ui = "/org/pepper/level_editor_preferences_dialog.ui")]
+	public class PreferencesDialog : Gtk.Dialog
+	{
+		// Data
+		ConsoleClient _engine;
+
+		// Widgets
+		[GtkChild]
+		Gtk.ColorButton _grid_color_button;
+
+		[GtkChild]
+		Gtk.ColorButton _grid_disabled_color_button;
+
+		[GtkChild]
+		Gtk.ColorButton _axis_x_color_button;
+
+		[GtkChild]
+		Gtk.ColorButton _axis_y_color_button;
+
+		[GtkChild]
+		Gtk.ColorButton _axis_z_color_button;
+
+		[GtkChild]
+		Gtk.ColorButton _axis_selected_color_button;
+
+		public PreferencesDialog(ConsoleClient engine)
+		{
+			// Data
+			_engine = engine;
+		}
+
+		private static Vector3 rgba_to_vector3(Gdk.RGBA rgba)
+		{
+			double r = rgba.red;
+			double g = rgba.green;
+			double b = rgba.blue;
+			return Vector3(r, g, b);
+		}
+
+		[GtkCallback]
+		private void on_color_set()
+		{
+			_engine.send_script(LevelEditorApi.set_color("grid", rgba_to_vector3(_grid_color_button.get_rgba())));
+			_engine.send_script(LevelEditorApi.set_color("grid_disabled", rgba_to_vector3(_grid_disabled_color_button.get_rgba())));
+			_engine.send_script(LevelEditorApi.set_color("axis_x", rgba_to_vector3(_axis_x_color_button.get_rgba())));
+			_engine.send_script(LevelEditorApi.set_color("axis_y", rgba_to_vector3(_axis_y_color_button.get_rgba())));
+			_engine.send_script(LevelEditorApi.set_color("axis_z", rgba_to_vector3(_axis_z_color_button.get_rgba())));
+			_engine.send_script(LevelEditorApi.set_color("axis_selected", rgba_to_vector3(_axis_selected_color_button.get_rgba())));
+		}
+	}
+}

+ 251 - 214
tools/ui/level_editor_preferences_dialog.ui

@@ -2,223 +2,260 @@
 <!-- Generated with glade 3.20.0 -->
 <interface>
   <requires lib="gtk+" version="3.14"/>
-  <template class="__glade_unnamed_5" parent="GtkGrid">
-    <property name="visible">True</property>
+  <template class="CrownPreferencesDialog" parent="GtkDialog">
     <property name="can_focus">False</property>
-    <property name="row_spacing">6</property>
-    <child>
-      <object class="GtkLabel">
-        <property name="visible">True</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox">
         <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Grid</property>
-        <property name="xalign">0</property>
-        <attributes>
-          <attribute name="weight" value="bold"/>
-        </attributes>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkGrid">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">12</property>
+            <property name="row_spacing">6</property>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Grid</property>
+                <property name="xalign">0</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkColorButton" id="_grid_color_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="hexpand">True</property>
+                <property name="use_alpha">True</property>
+                <property name="alpha">65535</property>
+                <property name="rgba">rgb(102,102,102)</property>
+                <property name="show_editor">True</property>
+                <signal name="color-set" handler="on_color_set" swapped="no"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_right">12</property>
+                <property name="label" translatable="yes">Grid</property>
+                <property name="xalign">1</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkColorButton" id="_grid_disabled_color_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="hexpand">True</property>
+                <property name="use_alpha">True</property>
+                <property name="alpha">26214</property>
+                <property name="rgba">rgb(102,102,102)</property>
+                <property name="show_editor">True</property>
+                <signal name="color-set" handler="on_color_set" swapped="no"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_right">12</property>
+                <property name="label" translatable="yes">Grid (Disabled)</property>
+                <property name="xalign">1</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Axes</property>
+                <property name="xalign">0</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">3</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkColorButton" id="_axis_x_color_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="hexpand">True</property>
+                <property name="use_alpha">True</property>
+                <property name="alpha">65535</property>
+                <property name="rgba">rgb(217,0,0)</property>
+                <property name="show_editor">True</property>
+                <signal name="color-set" handler="on_color_set" swapped="no"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">4</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_right">12</property>
+                <property name="label" translatable="yes">X Axis</property>
+                <property name="xalign">1</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">4</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_right">12</property>
+                <property name="label" translatable="yes">Y Axis</property>
+                <property name="xalign">1</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">5</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_right">12</property>
+                <property name="label" translatable="yes">Z Axis</property>
+                <property name="xalign">1</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">6</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkColorButton" id="_axis_y_color_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="hexpand">True</property>
+                <property name="use_alpha">True</property>
+                <property name="alpha">65535</property>
+                <property name="rgba">rgb(0,217,0)</property>
+                <property name="show_editor">True</property>
+                <signal name="color-set" handler="on_color_set" swapped="no"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">5</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkColorButton" id="_axis_z_color_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="hexpand">True</property>
+                <property name="use_alpha">True</property>
+                <property name="alpha">65535</property>
+                <property name="rgba">rgb(0,0,217)</property>
+                <property name="show_editor">True</property>
+                <signal name="color-set" handler="on_color_set" swapped="no"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">6</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_right">12</property>
+                <property name="label" translatable="yes">Selected</property>
+                <property name="xalign">1</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">7</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkColorButton" id="_axis_selected_color_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_alpha">True</property>
+                <property name="alpha">65535</property>
+                <property name="rgba">rgb(217,217,0)</property>
+                <property name="show_editor">True</property>
+                <signal name="color-set" handler="on_color_set" swapped="no"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">7</property>
+              </packing>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
       </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">0</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkColorButton" id="grid_color_button">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
-        <property name="hexpand">True</property>
-        <property name="use_alpha">True</property>
-        <property name="alpha">65535</property>
-        <property name="rgba">rgb(102,102,102)</property>
-        <property name="show_editor">True</property>
-        <signal name="color-set" handler="color_set" swapped="no"/>
-      </object>
-      <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">1</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin_right">12</property>
-        <property name="label" translatable="yes">Grid</property>
-        <property name="xalign">1</property>
-      </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">1</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkColorButton" id="grid_disabled_color_button">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
-        <property name="hexpand">True</property>
-        <property name="use_alpha">True</property>
-        <property name="alpha">26214</property>
-        <property name="rgba">rgb(102,102,102)</property>
-        <property name="show_editor">True</property>
-        <signal name="color-set" handler="color_set" swapped="no"/>
-      </object>
-      <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">2</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin_right">12</property>
-        <property name="label" translatable="yes">Grid (Disabled)</property>
-        <property name="xalign">1</property>
-      </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">2</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Axes</property>
-        <property name="xalign">0</property>
-        <attributes>
-          <attribute name="weight" value="bold"/>
-        </attributes>
-      </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">3</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkColorButton" id="axis_x_color_button">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
-        <property name="hexpand">True</property>
-        <property name="use_alpha">True</property>
-        <property name="alpha">65535</property>
-        <property name="rgba">rgb(217,0,0)</property>
-        <property name="show_editor">True</property>
-        <signal name="color-set" handler="color_set" swapped="no"/>
-      </object>
-      <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">4</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin_right">12</property>
-        <property name="label" translatable="yes">X Axis</property>
-        <property name="xalign">1</property>
-      </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">4</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin_right">12</property>
-        <property name="label" translatable="yes">Y Axis</property>
-        <property name="xalign">1</property>
-      </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">5</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin_right">12</property>
-        <property name="label" translatable="yes">Z Axis</property>
-        <property name="xalign">1</property>
-      </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">6</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkColorButton" id="axis_y_color_button">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
-        <property name="hexpand">True</property>
-        <property name="use_alpha">True</property>
-        <property name="alpha">65535</property>
-        <property name="rgba">rgb(0,217,0)</property>
-        <property name="show_editor">True</property>
-        <signal name="color-set" handler="color_set" swapped="no"/>
-      </object>
-      <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">5</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkColorButton" id="axis_z_color_button">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
-        <property name="hexpand">True</property>
-        <property name="use_alpha">True</property>
-        <property name="alpha">65535</property>
-        <property name="rgba">rgb(0,0,217)</property>
-        <property name="show_editor">True</property>
-        <signal name="color-set" handler="color_set" swapped="no"/>
-      </object>
-      <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">6</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin_right">12</property>
-        <property name="label" translatable="yes">Selected</property>
-        <property name="xalign">1</property>
-      </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">7</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkColorButton" id="selected_color_button">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
-        <property name="use_alpha">True</property>
-        <property name="alpha">65535</property>
-        <property name="rgba">rgb(217,217,0)</property>
-        <property name="show_editor">True</property>
-      </object>
-      <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">7</property>
-      </packing>
-    </child>
-    <child>
-      <placeholder/>
-    </child>
-    <child>
-      <placeholder/>
     </child>
   </template>
 </interface>