Quellcode durchsuchen

Merge branch 'lua-env' of https://github.com/taylor001/crown into lua-env

mikymod vor 12 Jahren
Ursprung
Commit
1baf0a5e46

+ 2 - 1
tools/CMakeLists.txt

@@ -11,6 +11,7 @@ include_directories(${INCLUDES} ${GTKMM_INCLUDE_DIRS})
 
 
 add_subdirectory(compilers)
 add_subdirectory(compilers)
 #add_subdirectory(editors/world-editor)
 #add_subdirectory(editors/world-editor)
-#add_subdirectory(editors/resource-browser)
+add_subdirectory(editors/resource-browser)
+add_subdirectory(editors/toolchain)
 add_subdirectory(pycrown)
 add_subdirectory(pycrown)
 
 

+ 1 - 1
tools/compilers/Compiler.cpp

@@ -62,7 +62,7 @@ size_t Compiler::compile(const char* resource, uint32_t name, uint32_t type)
 	char output_name[17];
 	char output_name[17];
 	snprintf(output_name, 17, "%.8X%.8X", name, type);
 	snprintf(output_name, 17, "%.8X%.8X", name, type);
 
 
-	Log::i("%s => %s", resource, output_name);
+	Log::i("%s <= %s", output_name, resource);
 
 
 	if (type != m_type_expected)
 	if (type != m_type_expected)
 	{
 	{

+ 4 - 0
tools/editors/toolchain/CMakeLists.txt

@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8)
+
+install (FILES toolchain.py DESTINATION bin)
+install (FILES ui/toolchain.glade DESTINATION bin/ui)

+ 77 - 0
tools/editors/toolchain/toolchain.py

@@ -0,0 +1,77 @@
+#!/usr/bin/python
+
+# Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+# Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
+# 
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+import sys
+import os
+import subprocess
+
+from gi.repository import Gtk
+
+from pycrown import Repository
+
+class Toolchain:
+	def __init__(self):
+
+		builder = Gtk.Builder()
+		builder.add_from_file("ui/toolchain.glade")
+
+		builder.connect_signals(self)
+
+		self.m_run_button = builder.get_object("run_button")
+		self.m_project_chooser = builder.get_object("project_chooser")
+
+		self.m_window = builder.get_object("window1")
+		self.m_window.set_title("Crown Toolchain")
+
+		self.m_window.show_all()
+
+		Gtk.main()
+
+	# Callback
+	def on_delete(self, *args):
+		Gtk.main_quit(*args)
+
+	def on_project_chooser_file_set(self, button):
+		self.m_run_button.set_sensitive(True)
+		self.m_root_path = button.get_filename()
+
+	def on_run_button_clicked(self, button):
+		root_path = str(self.m_root_path)
+		dest_path = root_path + "_compiled"
+
+		comp = subprocess.call(["python", "resource-compiler.py", str(self.m_root_path)])
+		crown = subprocess.call(["crown-linux", "--root-path", dest_path, "--dev"])
+
+	def on_browser_button_clicked(self, button):
+		browser = subprocess.call(["python", "resource-browser.py", str(self.m_root_path)])
+
+
+#------------------------------------------------------------------------------
+def main():
+	toolchain = Toolchain()
+
+main()
+

+ 193 - 0
tools/editors/toolchain/ui/toolchain.glade

@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.6 -->
+  <object class="GtkWindow" id="window1">
+    <property name="can_focus">False</property>
+    <property name="window_position">center-always</property>
+    <signal name="delete-event" handler="on_delete" swapped="no"/>
+    <child>
+      <object class="GtkBox" id="box1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="margin_left">10</property>
+        <property name="margin_right">10</property>
+        <property name="margin_top">10</property>
+        <property name="margin_bottom">10</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">10</property>
+        <child>
+          <object class="GtkGrid" id="grid1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="row_spacing">10</property>
+            <property name="column_spacing">10</property>
+            <child>
+              <object class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Project:</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Platform:</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Target:</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFileChooserButton" id="project_chooser">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="action">select-folder</property>
+                <signal name="file-set" handler="on_project_chooser_file_set" swapped="no"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="platform_combobox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="target_combobox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="run_button">
+                <property name="label" translatable="yes">Run</property>
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <signal name="clicked" handler="on_run_button_clicked" swapped="no"/>
+              </object>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="box2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">10</property>
+            <child>
+              <object class="GtkButton" id="browser_button">
+                <property name="label" translatable="yes">Resource browser</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <signal name="clicked" handler="on_browser_button_clicked" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button3">
+                <property name="label" translatable="yes">World editor</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button4">
+                <property name="label" translatable="yes">Something else</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>

+ 0 - 11
tools/pycrown/Compiler.py

@@ -116,22 +116,11 @@ class Compiler:
 
 
 	# Compiles all the resources in the repository
 	# Compiles all the resources in the repository
 	def compile_all(self):
 	def compile_all(self):
-		print("Compiling textures...")
 		self.compile_textures()
 		self.compile_textures()
-
-		print("Compiling meshes...")
 		self.compile_meshes()
 		self.compile_meshes()
-
-		print("Compiling texts...")
 		self.compile_texts()
 		self.compile_texts()
-
-		print("Compiling scripts...")
 		self.compile_scripts()
 		self.compile_scripts()
-
-		print("Compiling vertex shaders...")
 		self.compile_vertex_shaders()
 		self.compile_vertex_shaders()
-
-		print("Compiling pixel shaders...")
 		self.compile_pixel_shaders()
 		self.compile_pixel_shaders()
 
 
 	# Compile a single resource from the repository
 	# Compile a single resource from the repository

+ 6 - 1
tools/pycrown/Repository.py

@@ -37,8 +37,13 @@ resource_extensions = ('.txt', '.tga', '.dae', '.lua', '.vs', '.ps')
 # Can filter resources by type and other useful stuff
 # Can filter resources by type and other useful stuff
 class Repository:
 class Repository:
 	def __init__(self, root_path):
 	def __init__(self, root_path):
-		self.m_root_path = root_path
 		self.m_resources = []
 		self.m_resources = []
+		self.set_root_path(root_path)
+
+	# Sets the root path triggering a complete project scan()
+	def set_root_path(self, root_path):
+		self.m_root_path = root_path
+		self.scan()
 
 
 	# Returns the root path
 	# Returns the root path
 	def root_path(self):
 	def root_path(self):