Philémon Gardet avatar Philémon Gardet committed 5d69782

Ajout du traitement de fonction proprietaire qui se lance des que le joueur a arrete de bouger.

Comments (0)

Files changed (2)

 		(* Game Mode *)
 		val player = envString#get "player"
 		val displayData = new dictionary
+		val priorityFunc = Queue.create ()
+		
 		val mutable background = get_video_surface ()
 		val mutable currentRoom = None
 		val mutable currentDialog = None
+		
 		val mutable currentRuntime = None
 		val mutable nodes = None
 		
 			Sdlevent.enable_events (Sdlevent.make_mask [ 
 				Sdlevent.KEYDOWN_EVENT;
 				Sdlevent.MOUSEBUTTONDOWN_EVENT;
-				Sdlevent.QUIT_EVENT;
-				Sdlevent.USER_EVENT])
+				Sdlevent.QUIT_EVENT]
+			)
 		
 		(** Window Manager **)
 		method getSurface =
 					
 		(** Read Input User and run the function corresponding with event **)
 		(* Game Mode *)
-		method private gameInputUser = function 
-			| Sdlevent.KEYDOWN key ->
-				begin match key.Sdlevent.keysym with
-					| KEY_i -> self#setInventoryMode
-					| _ -> self#updateEvents
-				end
-			| Sdlevent.MOUSEBUTTONDOWN b when self#playerStill -> 
-				self#mouseClickUpdating b
-			| _ -> self#updateEvents
+		method private gameInputUser event = 
+			self#doPriorityFunc;
+			match event with
+				| Sdlevent.KEYDOWN key ->
+					begin match key.Sdlevent.keysym with
+						| KEY_i -> self#setInventoryMode
+						| _ -> self#updateEvents
+					end
+				| Sdlevent.MOUSEBUTTONDOWN b when self#playerStill -> 
+					self#mouseClickUpdating b
+				| _ -> self#updateEvents
 		
 		method private mouseClickUpdating b = 
 			let x = b.Sdlevent.mbe_x
 							self#walkToPos player (x,y)
 					| _ -> self#updateEvents
 		
+		method private doPriorityFunc =
+			if self#playerStill then while not(is_empty priorityFunc) do
+				pop priorityFunc ()
+			done
+		
 		(* Inventory Mode *)
 		method private inventoryInputUser = function
 		  | Sdlevent.KEYDOWN key -> 
 			let result = ref [] in
 			let rec browser = function
 				| VoidTree -> ()
-				| Node(Element(str, dict), brother, children) when String.lowercase str = String.lowercase name ->
-					let e = self#newXmlTree (Node(Element(str, dict), brother, children)) in
-					result := e::!result;
-					browser children;
-					browser brother
+				| Node(Element(str, dict), brother, children) 
+					when String.lowercase str = String.lowercase name ->
+						let e = self#newXmlTree (Node(Element(str, dict), brother, children)) 
+						in
+						result := e::!result;
+						browser children;
+						browser brother
 				| Node(_, brother, children) -> 
 					browser children;
 					browser brother
 			in browser data; !result
 		method getFirstByName name =
 			let rec browser = function
-                                | VoidTree -> VoidTree
-                                | Node(Element(str, dict), brother, children) 
+				| VoidTree -> VoidTree
+				| Node(Element(str, dict), brother, children)
 					when String.lowercase str = String.lowercase name ->
-					Node(Element(str, dict), brother, children)
-                                | Node(_, brother, children) ->
-                                        let resultChildren = browser children in
-                                        if resultChildren = VoidTree then
-                                                browser brother
-                                        else
-                                                resultChildren
-                        in
-                        let result = browser data in
-                        if result = VoidTree then
-                                raise Not_found
-                        else
-                                self#newXmlTree result
+						Node(Element(str, dict), brother, children)
+				| Node(_, brother, children) ->
+					let resultChildren = browser children in
+					if resultChildren = VoidTree then
+						browser brother
+					else
+						resultChildren
+			in
+			let result = browser data in
+			if result = VoidTree then
+				raise Not_found
+			else
+				self#newXmlTree result
 	end
 ;;
 
 		val mutable keys = []
 		val mutable n = ref (-1)
 		val mutable aux = VoidM
-
+		
+		val changingRoom = new dictionary
 		
 		val mutable currentNode = ""
 		
 				!final
 			end
 		method private getNodes =
-			print_string(((tree#getFirstByName "graph")#getXmlElement ())#getName ()^"\n"); (* test de conformité du fichier graph *)
+			(* Debug ** print_string(((tree#getFirstByName "graph")#getXmlElement ())#getName ()^"\n");  test de conformité du fichier graph *)
 			nodes <- tree#getElementsByName "node"
 		method getFirst =
 			let n = nodes in
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.