From dcf6328ca18be0e59f5015d07347e0cc7830122f Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Fri, 15 Jan 2016 21:34:26 -0800 Subject: [PATCH] logging --- desktop/last-release | 2 +- desktop/project.clj | 5 +-- desktop/src-common/advent/actions.clj | 3 +- desktop/src-common/advent/core.clj | 3 +- desktop/src-common/advent/pathfind.clj | 1 - .../src-common/advent/screens/rooms/dream.clj | 2 +- .../advent/screens/rooms/outside_house.clj | 2 +- desktop/src-common/advent/screens/scene.clj | 31 +++++-------------- desktop/src-common/advent/utils.clj | 11 ++++--- desktop/src/advent/core/desktop_launcher.clj | 17 ++-------- 10 files changed, 26 insertions(+), 51 deletions(-) diff --git a/desktop/last-release b/desktop/last-release index f5c89552..a7873645 100644 --- a/desktop/last-release +++ b/desktop/last-release @@ -1 +1 @@ -32 +34 diff --git a/desktop/project.clj b/desktop/project.clj index aa642bea..8ef65989 100644 --- a/desktop/project.clj +++ b/desktop/project.clj @@ -9,10 +9,11 @@ [com.badlogicgames.gdx/gdx-backend-lwjgl "1.5.3"] [com.badlogicgames.gdx/gdx-platform "1.5.3" :classifier "natives-desktop"] [org.clojure/clojure "1.6.0"] - [play-clj "0.4.5-BRYCE"] + [log4j/log4j "1.2.16"] [org.clojure/data.priority-map "0.0.5"] - [org.clojure/core.async "0.1.338.0-5c5012-alpha"]] + [org.clojure/core.async "0.1.338.0-5c5012-alpha"] + [org.clojure/tools.logging "0.3.1"]] :source-paths ["src" "src-common"] :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"] :omit-source true diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 1cc5f61c..c18f4c3b 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -7,6 +7,7 @@ [clojure.string :as s] [clojure.zip :as zip] [clojure.set :as set] + [clojure.tools.logging :as log] [advent.pathfind] [advent.actions :as actions] [advent.screens.dialogue :as dialogue] @@ -60,7 +61,7 @@ (let [result# ( entities entities - (if (doto (get-in entities [:state :seen-intro?]) println) + (if (get-in entities [:state :seen-intro?]) (set-opacity entities 1.0 1.0) (set-opacity entities 0.0 0.0)) (if (actions/has-item? entities :broom) diff --git a/desktop/src-common/advent/screens/rooms/outside_house.clj b/desktop/src-common/advent/screens/rooms/outside_house.clj index 1757ccff..29a1e0ae 100644 --- a/desktop/src-common/advent/screens/rooms/outside_house.clj +++ b/desktop/src-common/advent/screens/rooms/outside_house.clj @@ -705,7 +705,7 @@ (do (walk-to-sheep entities) (actions/play-animation entities :ego :reach) (actions/update-state entities #(assoc % :wool-count (inc (or (:wool-count %) 0)))) - (when (= 3 (doto (get-in @entities [:state :wool-count]) println)) + (when (= 3 (get-in @entities [:state :wool-count])) (steam/set-achievement "SHEEP_HORDER")) (actions/update-entities entities #(update-in diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index fbe10c61..0c64b454 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -9,6 +9,7 @@ [clojure.zip :as zip] [clojure.pprint] [clojure.java.io :as io] + [clojure.tools.logging :as log] [advent.pathfind] [advent.actions :as actions] [advent.zone :as zone] @@ -202,7 +203,7 @@ void main () (= :end (actions/skip-type current-action screen entities)) (let [terminated-entities (actions/terminate current-action screen entities)] - (println "trying to end") + (log/info "Attempting to end action") (actions/force-end terminated-entities current-action :fg-actions) ) :else @@ -213,7 +214,7 @@ void main () (get-in entities [:room :interactions]))) ) (defn get-interacting-entity [entities x y] - (let [interactable-entities (if (= (doto (get-in entities [:cursor :current]) println) :main) + (let [interactable-entities (if (= (doto (get-in entities [:cursor :current]) (#(log/info "clicked with " %)) ) :main) (vals (dissoc (get-in entities [:room :entities]) :ego)) (vals (get-in entities [:room :entities]))) interacting-entity (first (sort-by (comp - :baseline) @@ -225,7 +226,7 @@ void main () (defn left-click [screen entities] (let [[x y] (utils/unproject screen) - _ (println "clicked " x y) + _ (log/info (str "clicked " x y)) interaction (get-interaction entities x y) interacting-entity (get-interacting-entity entities x y) current-action (get-in entities [:fg-actions :current]) @@ -785,7 +786,7 @@ void main () (if next-script (do (next-script entities) - (println "starting script") + (log/info "starting script") (assoc-in entities [key :script-running?] true)) entities))))) @@ -991,25 +992,7 @@ void main () e))) -(defn shift-range-to-bounds [x1 x2 min max] - (println x1 x2 "->" (cond (and (< x1 min) - (> x2 max)) - [min max] - (< x1 min) - [min (+ x2 (- min x1))] - (> x2 max) - [(- x1 (- x2 max)) max] - :else - [x1 x2])) - (cond (and (< x1 min) - (> x2 max)) - [min max] - (< x1 min) - [min (+ x2 (- min x1))] - (> x2 max) - [(- x1 (- x2 max)) max] - :else - [x1 x2])) + (defn mouse-moved [{:keys [input-x input-y viewport] :as screen} [entities]] (utils/update-override screen (assoc-in entities [:cursor :last-pos] [input-x input-y]))) @@ -1054,7 +1037,7 @@ void main () (let [[^OrthographicCamera cam] (utils/setup-viewport screen 320 240)] (set! (. cam zoom) 0.95) (let [shader (ShaderProgram. ^String v-shader ^String pix-shader) - #_#__ (println (.getLog shader)) + #_#__ (log/info "shader log:" (.getLog shader)) state (get-state @utils/selected-save) start-pos [(:x state) (:y state)] has-start-pos? (:x state) diff --git a/desktop/src-common/advent/utils.clj b/desktop/src-common/advent/utils.clj index 05e07451..9d5b14c7 100644 --- a/desktop/src-common/advent/utils.clj +++ b/desktop/src-common/advent/utils.clj @@ -8,6 +8,7 @@ [play-clj.entities :refer [->TextureEntity]] [clojure.java.io :as io] [clojure.edn :as edn] + [clojure.tools.logging :as log] [clojure.string :as str] [advent.saves :as saves] [advent.steam :as steam]) @@ -24,7 +25,7 @@ (defn log-coords [screen entities] (let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})] - (println (:input-x screen) (:input-y screen) "->" x y))) + (log/info (:input-x screen) (:input-y screen) "->" x y))) (def +all-cursors+ [:main :wool :mushrooms :carrot :right :down :left :up :flask :flask-with-contents :trophy :ladder :stick :cat-toy :balloon :frog-legs :teddy :portrait :recipe :glass-eye :motivational-tapes :used-earplugs :grass :slobber :flask-with-strength :medal :kiss :sword :hourglass :mandrake :ball-n-chain :key :rope :crowbar :note-1 :ash :sack-lunch :flies :spear :monocle :feather :spell-component :money :charcoal :broken-clock :slingshot :camera :walkie-talkies :alarm-clock :walkie-talkie :flask-water :flask-water-stuff :flask-water-stuff-2 :note-2 :magic-slingshot :active-main :shovel :broom]) @@ -294,7 +295,7 @@ (try (sound f) (catch Exception e - (println e) + (log/info e) (sound (str f ".mp3"))))) @@ -430,8 +431,8 @@ (try (if val (on-gl (.setDisplayMode Gdx/graphics - (doto (.width (.getDesktopDisplayMode Gdx/graphics)) println) - (doto (.height (.getDesktopDisplayMode Gdx/graphics)) println) + (doto (.width (.getDesktopDisplayMode Gdx/graphics)) log/info) + (doto (.height (.getDesktopDisplayMode Gdx/graphics)) log/info) true) (set! (.foregroundFPS (-> (class Gdx/graphics) (.getDeclaredField (name "config")) @@ -443,7 +444,7 @@ (save-settings!)) nil (catch Exception e - (println e)))) + (log/error e)))) (defn toggle-fullscreen! [] (if (.isFullscreen Gdx/graphics) diff --git a/desktop/src/advent/core/desktop_launcher.clj b/desktop/src/advent/core/desktop_launcher.clj index 44c1e263..38ec50f3 100644 --- a/desktop/src/advent/core/desktop_launcher.clj +++ b/desktop/src/advent/core/desktop_launcher.clj @@ -1,7 +1,8 @@ (ns advent.core.desktop-launcher (:require [advent.core :refer :all] [advent.utils :as utils] - [play-clj.core :refer :all]) + [play-clj.core :refer :all] + [clojure.tools.logging :as log]) (:import [com.badlogic.gdx.backends.lwjgl LwjglApplication LwjglApplicationConfiguration] [org.lwjgl.input Keyboard] [com.badlogic.gdx Gdx Files$FileType]) @@ -14,31 +15,19 @@ (require '[play-clj-nrepl.core :as a]) (System/getProperty "use-repl") (catch Exception e - (println e) false))) (defn -main [& [port]] (when has-nrepl? - (play-clj-nrepl.core/start-nrepl advent.core/advent port)) + (eval `(play-clj-nrepl.core/start-nrepl advent.core/advent ~port))) (let [cfg (LwjglApplicationConfiguration.)] - #_(println (.exists (files! :classpath "icon/icon_128x128.png"))) (.addIcon cfg "icon/icon_128x128.png" Files$FileType/Classpath) (.addIcon cfg "icon/icon_32x32.png" Files$FileType/Classpath) (.addIcon cfg "icon/icon_16x16.png" Files$FileType/Classpath) - (if false - (do - (set! (.width cfg) (doto (.width (LwjglApplicationConfiguration/getDesktopDisplayMode)) println)) - (set! (.height cfg) (doto (.height (LwjglApplicationConfiguration/getDesktopDisplayMode)) println)) - (set! (.resizable cfg) true) - (set! (.useHDPI cfg) false) - (set! (.fullscreen cfg) true)) - (do - (set! (.width cfg) 1280) - (set! (.height cfg) 960))) (set! (.title cfg) "Tick's Tales: Up All Knight") (set! (.foregroundFPS cfg) 60) (set! (.backgroundFPS cfg) 60)