Переглянути джерело

Delete old python console

Daniele Bartolini 12 роки тому
батько
коміт
5ccee3b180

+ 0 - 6
tools/gui/console/CMakeLists.txt

@@ -1,6 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-install (FILES console.py PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
-	GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION tools)
-
-install (FILES ui/console.glade DESTINATION tools/ui)

+ 0 - 243
tools/gui/console/console.py

@@ -1,243 +0,0 @@
-#!/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 socket
-import threading
-
-from gi.repository import Gtk
-
-# Client Console commands
-CMD_CLEAR   = "clear"           # Clear console output
-CMD_EXIT_1  = "exit"            # Close console
-CMD_EXIT_2  = "Device.stop()"   # Close console
-CMD_HELP    = "help"            # Console help
-CMD_HISTORY = "history"         # History
-CMD_VOID    = ""
-
-
-class ReaderThread(threading.Thread):
-#------------------------------------------------------------------------------
-    def __init__(self, console):
-        threading.Thread.__init__(self)
-        self.t_console = console
-        self.t_stop = threading.Event()
-        self.t_is_running = True
-
-#------------------------------------------------------------------------------
-    def stop(self):
-        self.t_stop.set()
-        self.t_is_running = False
-
-
-#------------------------------------------------------------------------------
-    def stopped(self):
-        return self.t_stop.isSet()
-
-#------------------------------------------------------------------------------
-    def run(self):
-        while self.t_is_running:
-            self.t_tmp = self.t_console.m_sock.recv(1024)
-
-            if self.t_tmp != "":
-                self.t_tmp = self.t_tmp.decode("utf-8")
-                self.t_error = self.t_tmp.split('\x00', 1)[0]
-                self.t_console.print_error(self.t_error)
-
-
-class ConsoleHistory:
-#------------------------------------------------------------------------------
-    def __init__(self):
-        self.m_list = list()
-        self.m_count = 0
-        self.m_index = 0
-
-#------------------------------------------------------------------------------
-    def add(self, cmd):
-        self.m_list.append(cmd)
-        self.m_count += 1
-        self.m_index = self.m_count
-
-#------------------------------------------------------------------------------
-    def previous(self):
-        if self.m_count != 0:
-            self.m_index -= 1
-
-            if self.m_index < 0:
-                self.m_index = 0
-
-            return self.m_list[self.m_index]
-
-        return ""
-
-#------------------------------------------------------------------------------
-    def following(self):
-        if self.m_count != 0:
-            self.m_index += 1
-
-            if self.m_index > self.m_count-1:
-                self.m_index = self.m_count - 1
-
-            return self.m_list[self.m_index]
-
-        return ""
-
-
-class Console:
-#------------------------------------------------------------------------------
-    def __init__(self, address):   
-        builder = Gtk.Builder()
-        builder.add_from_file("ui/console.glade")
-        
-        self.m_view = builder.get_object("textview1")
-        self.m_buffer = builder.get_object("textbuffer1")
-        self.m_entry = builder.get_object("entry1")
-        
-        self.m_window = builder.get_object('window1')
-        self.m_window.set_title("Crown Console")      
-        self.m_window.show_all()
-
-        builder.connect_signals(self)
-
-        self.m_address = address
-        self.m_error_buffer = ""
-
-        self.history = ConsoleHistory()
-
-        self.m_sock = socket.create_connection((self.m_address, 10000))
-
-        self.m_thread = ReaderThread(self)
-        self.m_thread.start()
-
-        self.m_formatter = self.m_buffer.create_tag("console", foreground="green")
-
-        Gtk.main()
-
-#------------------------------------------------------------------------------
-    def on_destroy(self, *args):
-        self.m_sock.close()
-        self.m_thread.stop()
-        Gtk.main_quit(*args)
-
-#------------------------------------------------------------------------------
-    def on_key_pressed(self, entry, event):
-        # If return is pressed, run command
-        if event.keyval == 0xff0d:
-            cmd = entry.get_text()
-            self.parse_command(cmd)
-            return True
-
-        if event.keyval == 0xff52:
-            cmd = self.history.previous()
-            self.print_to_entry(cmd)
-            return True
-
-        if event.keyval == 0xff54:
-            cmd = self.history.following()
-            self.print_to_entry(cmd)
-            return True
-
-
-#------------------------------------------------------------------------------
-    def parse_command(self, cmd):
-        self.history.add(cmd)
-
-        if cmd == CMD_CLEAR:
-            self.m_buffer.set_text("")
-            self.m_entry.set_text("")
-
-        elif cmd == CMD_EXIT_1:
-            self.on_destroy()  
-
-        elif cmd == CMD_EXIT_2:
-            self.run_command(cmd)                  
-            self.on_destroy() 
-
-        elif cmd == CMD_HELP:
-            self.print_help()
-
-        elif cmd == CMD_VOID:
-            self.print_command("");
-
-        else:    
-            self.run_command(cmd)        
-
-#------------------------------------------------------------------------------
-    def run_command(self, cmd):
-        self.m_sock.send(cmd.encode('utf-8'))
-        self.print_command(cmd)
-
-#------------------------------------------------------------------------------
-    def print_command(self, text):
-        # Print command to console
-        start_iter = self.m_buffer.get_end_iter()       
-
-        a_string = "> " + text + "\n"
-        # Append command to the end of buffer
-
-        self.m_buffer.insert(start_iter, a_string, len(a_string))
-
-        self.m_view.scroll_mark_onscreen(self.m_buffer.get_insert())
-
-        # Reset entry
-        self.print_to_entry("")
-
-#------------------------------------------------------------------------------
-    def print_error(self, text):
-        start_iter = self.m_buffer.get_end_iter()  
-
-        a_string = "> " + text + "\n"
-
-        self.m_buffer.insert(start_iter, a_string, len(a_string))
-
-        self.m_view.scroll_mark_onscreen(self.m_buffer.get_insert())
-
-#------------------------------------------------------------------------------
-    def print_to_entry(self, text):
-        self.m_entry.set_text(text)
-
-#------------------------------------------------------------------------------
-    # def popup_dialog(self, message, expl):
-    #     dialog = Gtk.MessageDialog(self.m_window, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, message)
-    #     dialog.format_secondary_text(expl)
-    #     dialog.run()
-    #     dialog.destroy()
-
-#------------------------------------------------------------------------------
-#------------------------------------------------------------------------------
-def main():
-    if len(sys.argv) != 2:
-        print("Usage: console.py <ip-address>")
-        exit(-1)
-
-    address = sys.argv[1]
-
-    console = Console(address)
-
-
-main()
-    

+ 0 - 59
tools/gui/console/ui/console.glade

@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
-  <!-- interface-requires gtk+ 3.6 -->
-  <object class="GtkTextBuffer" id="textbuffer1"/>
-  <object class="GtkWindow" id="window1">
-    <property name="can_focus">False</property>
-    <property name="border_width">6</property>
-    <property name="default_width">600</property>
-    <property name="default_height">330</property>
-    <signal name="destroy" handler="on_destroy" swapped="no"/>
-    <child>
-      <object class="GtkBox" id="box1">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <child>
-          <object class="GtkEntry" id="entry1">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="has_focus">True</property>
-            <property name="progress_pulse_step">0</property>
-            <signal name="key-press-event" handler="on_key_pressed" swapped="no"/>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow1">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="hscrollbar_policy">never</property>
-            <property name="vscrollbar_policy">always</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkTextView" id="textview1">
-                <property name="height_request">339</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="editable">False</property>
-                <property name="cursor_visible">False</property>
-                <property name="buffer">textbuffer1</property>
-                <property name="accepts_tab">False</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-  </object>
-</interface>

+ 0 - 12
tools/pycrown/CMakeLists.txt

@@ -1,12 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-project(pycrown)
-
-set (PYFILES
-	__init__.py
-	Repository.py
-	Compiler.py
-)
-
-install (FILES ${PYFILES} DESTINATION tools/pycrown)
-

+ 0 - 148
tools/pycrown/Compiler.py

@@ -1,148 +0,0 @@
-# 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 subprocess
-import os
-
-LUAJIT = "./luajit"
-OPTION = "-b"
-COMPILER_NAME = "./resource-compiler"
-RES_H = "./resource-hash"
-
-ROOT_P = "--root-path"
-DEST_P = "--dest-path"
-RES_IN = "--resource-in"
-SEED = "--seed"
-
-# Compiler is an helper for compiling resources in a repository
-# either one by one or in a whole
-class Compiler:
-	def __init__(self, repository, dest_path):
-		self.m_repository = repository
-		self.m_perfect_seed = -1
-		self.m_dest_path = dest_path
-
-	# Returns the destination path where the compiled
-	# resources will be put
-	def dest_path(self):
-		return self.m_dest_path
-
-	# Returns the perfect seed
-	def perfect_seed(self):
-		return self.m_perfect_seed
-
-	# Computes a perfect seed for the resources contained
-	# in the repository
-	def compute_perfect_seed(self):
-		# Obtain resources from repository
-		resources = self.m_repository.all_resources()
-
-		resource_hashes = []
-
-		seed = 0
-
-		# Calculate the hash resource by resource
-		# Note: we can speed-up this process by modifying resource-hash to
-		# calculate more than a hash at time...
-		while True:
-			for res in resources:
-				p = subprocess.check_output([RES_H, RES_IN, res, SEED, str(seed)])
-				resource_hashes.append(str(p))
-
-			if len(resource_hashes) == len(set(resource_hashes)):
-				self.m_perfect_seed = seed
-				return
-
-			resource_hashes.clear()
-			seed = seed + 1;
-
-	# Compiles all the texture resources in the repository
-	def compile_textures(self):
-		self.compile(self.m_repository.texture_resources());
-
-	# Compiles all the mesh resources in the repository
-	def compile_meshes(self):
-		self.compile(self.m_repository.mesh_resources());
-
-	# Compiles all the text resources in the repository
-	def compile_texts(self):
-		self.compile(self.m_repository.text_resources());
-
-	# Compiles all the script resources in the repository
-	def compile_scripts(self):
-		lua_resources = self.m_repository.script_resources()
-		root_path = self.m_repository.root_path()
-
-		for res in lua_resources:
-			path_in = os.path.normpath(root_path + "/" + res)
-			path_out = os.path.normpath(os.path.dirname(self.m_dest_path + "/" + res))
-
-			if not os.path.exists(path_out):
-				os.makedirs(path_out)
-
-			head, out_filename = os.path.split(res)
-			out_filename, ext = os.path.splitext(out_filename)
-
-			res_in = res
-			res_out = out_filename + ".raw"
-
-			print(res_out, "<=", res_in)
-
-			f = subprocess.call([LUAJIT, OPTION, path_in, path_out + "/" + res_out]);
-	
-	# Compiles all the vertex shader resources in the repository
-	def compile_vertex_shaders(self):
-		self.compile(self.m_repository.vertex_shader_resources());
-
-	# Compiles all the vertex shader resources in the repository
-	def compile_pixel_shaders(self):
-		self.compile(self.m_repository.pixel_shader_resources());
-
-	def compile_sounds(self):
-		self.compile(self.m_repository.sound_resources());
-
-	# Compiles all the resources in the repository
-	def compile_all(self):
-		self.compile_textures()
-		self.compile_meshes()
-		self.compile_texts()
-		self.compile_scripts()
-		self.compile_vertex_shaders()
-		self.compile_pixel_shaders()
-		self.compile_sounds()
-
-	# Compile a single resource from the repository
-	def compile(self, resources):
-		if (len(resources) == 0):
-			return
-
-		# Compute perfect seed if necessary
-		if (self.m_perfect_seed == -1):
-			self.compute_perfect_seed()
-
-		root_path = self.m_repository.root_path()
-		resource_params = (' '.join(resources)).split();
-		compiler_params = [COMPILER_NAME, "--root-path", root_path, "--dest-path", self.m_dest_path, "--seed", str(self.m_perfect_seed)]
-
-		p = subprocess.call(compiler_params + resource_params)

+ 0 - 145
tools/pycrown/Repository.py

@@ -1,145 +0,0 @@
-# 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 os
-
-TEXTURE_EXTENSION			= ('.tga')
-TEXT_EXTENSION				= ('.txt')
-MESH_EXTENSION				= ('.dae')
-LUA_EXTENSION				= ('.lua')
-VERTEX_SHADER_EXTENSION		= ('.vs')
-PIXEL_SHADER_EXTENSION		= ('.ps')
-SOUND_EXTENSION				= ('.wav')
-
-resource_extensions = ('.txt', '.tga', '.dae', '.lua', '.vs', '.ps', '.wav')
-
-# Represents the folder containing the resources
-# Can filter resources by type and other useful stuff
-class Repository:
-	def __init__(self, root_path):
-		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
-	def root_path(self):
-		return self.m_root_path
-
-	# Returns a list of all the resources found
-	def all_resources(self):
-		return self.m_resources
-
-	# Returns a list of all the texture resources found
-	def texture_resources(self):
-		textures = []
-
-		for res in self.m_resources:
-			if (res.endswith(TEXTURE_EXTENSION)):
-				textures.append(res)
-
-		return textures
-
-	# Returns a list of all the text resources found
-	def text_resources(self):
-		texts = []
-
-		for res in self.m_resources:
-			if (res.endswith(TEXT_EXTENSION)):
-				texts.append(res)
-
-		return texts
-
-	# Returns a list of all the mesh resources found
-	def mesh_resources(self):
-		meshes = []
-
-		for res in self.m_resources:
-			if (res.endswith(MESH_EXTENSION)):
-				meshes.append(res)
-
-		return meshes
-
-	# Returns a list of all the lua resources found
-	def script_resources(self):
-		scripts = []
-
-		for res in self.m_resources:
-			if (res.endswith(LUA_EXTENSION)):
-				scripts.append(res)
-
-		return scripts
-
-	# Returns a list of all the vertex shader resources found
-	def vertex_shader_resources(self):
-		vss = []
-
-		for res in self.m_resources:
-			if (res.endswith(VERTEX_SHADER_EXTENSION)):
-				vss.append(res)
-
-		return vss
-
-	# Returns a list of all the pixel shader resources found
-	def pixel_shader_resources(self):
-		pss = []
-
-		for res in self.m_resources:
-			if (res.endswith(PIXEL_SHADER_EXTENSION)):
-				pss.append(res)
-
-		return pss
-
-	# Returns a list of all the sound resources found
-	def sound_resources(self):
-		sounds = []
-
-		for res in self.m_resources:
-			if (res.endswith(SOUND_EXTENSION)):
-				sounds.append(res)
-
-		return sounds
-
-	# Scans the root path to find resources
-	def scan(self):
-		# Clear the resources
-		self.m_resources = []
-
-		for dirname, dirnames, filenames in os.walk(self.m_root_path):
-			for filename in filenames:
-				# Get the resource name
-				abs_path = os.path.join(dirname, filename)
-				resource_name = os.path.relpath(abs_path, self.m_root_path)
-
-				# Normalize resource name, OSs != Windows/Linux may need
-				# additional processing
-				resource_name = resource_name.replace("\\", "/")
-
-				# Filter resource names by type
-				if resource_name.endswith(resource_extensions):
-					self.m_resources.append(resource_name)
-

+ 0 - 0
tools/pycrown/__init__.py