Skip to content

Commit

Permalink
switch from figwheel to shadow-devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
emnh committed May 6, 2017
1 parent 8ab10d2 commit e117de2
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 18 deletions.
27 changes: 23 additions & 4 deletions README.md
@@ -1,5 +1,7 @@
# Introduction (Legacy version)

My blog about the project [is here](https://emnh.github.io/rts-blog/).

Unfinished project.
You can see a [demo displaying only free 3D models, not from SC2](http://emh.lart.no/publish/rts-free.git/).
The SC2 demo is not working because SC2 file host is not hosting them anymore,
Expand All @@ -11,9 +13,6 @@ SC2 files were retrieved from
[viewer.hiveworkshop.com](http://viewer.hiveworkshop.com/?q=Assets/units/zerg/baneling/baneling.m3)
(not mine) through a [heroku CORS proxy](http://crossorigin.herokuapp.com/).

Works best in Firefox, also in Chrome, not in IE and not tested with Safari.
Only tested on Windows.

If the demo doesn't work for you, you can watch videos of it at YouTube:
- [StarCraft 2 on WebGL](https://www.youtube.com/watch?v=PoPNrz2LUG0)
- [Starcraft 2 on WebGL with colorful UV mapping](https://www.youtube.com/watch?v=EvhUteDp3o8)
Expand Down Expand Up @@ -41,13 +40,33 @@ customize these for testing social logins or running a production server.

You will need a mongodb instance running on the default port (27017).

- Then open 2 terminals and run the following:
## Alternative 1: Using shadow-devtools build system

- Open 2 terminals and run the following:
```bash
./scripts/shadow-dev.sh
```
```bash
node node/server.js
```

- Now you can open [the dev page](http://localhost:3451/index.html#game-test)

I switched to shadow-devtools because the author, Thomas Heller, approached me personally if I wanted to use it.
The advantage is that it compiles in parallel and thus is faster than figwheel if you have a system with enough RAM.
The setup also needs a lot less configuration than figwheel, having good defaults.

## Alternative 2 (deprecated): Using figwheel build system
- Open 2 terminals and run the following:
```bash
./scripts/dev.sh
```
```bash
node js/figwheel.js
```

You will need to change index.html to comment in the figwheel stuff.

- Server figwheel runs on port 3450
- Node (with ClojureScript connected to figwheel on 3450) runs on port 3451
- Now you can open [the dev page](http://localhost:3451/index.html#game-test)
Expand Down
20 changes: 12 additions & 8 deletions resources/public/index.html
Expand Up @@ -36,21 +36,25 @@
</head>
<body>
<div id="pages" />
<script type="text/javascript" src="game.js"></script>
<!-- For figwheel -->
<!--<script type="text/javascript" src="game.js"></script>-->
<!-- For shadow-devtools -->
<script type="text/javascript" src="js/client.js"></script>
<script>
if (!window.location.hash || window.location.hash && window.location.hash == "#") {
window.location.hash = '#lobby';
}
if (window.location.hash && window.location.hash == '#_=_') {
window.location.hash = '#lobby';
}
if (document.location.hostname == 'localhost') {
console.log("dev mode");
goog.require('game.client.dev');
} else {
console.log("prod mode");
goog.require('game.client.core');
}
// For figwheel
// if (document.location.hostname == 'localhost') {
// console.log("dev mode");
// goog.require('game.client.dev');
// } else {
// console.log("prod mode");
// goog.require('game.client.core');
// }
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions scripts/shadow-dev.clj
Expand Up @@ -4,4 +4,6 @@
(cljs/start-worker :client)
(cljs/start-worker :server)

(cljs/sync :client)

(clojure.main/repl)
1 change: 1 addition & 0 deletions scripts/shadow-dev.sh
@@ -0,0 +1 @@
lein run -m clojure.main -i scripts/shadow-dev.clj -r
4 changes: 4 additions & 0 deletions shadow-cljs.edn
Expand Up @@ -3,6 +3,10 @@
:public-dir "resources/public/js"
:public-path "/js"

:devtools
{:before-load game.client.core/shadow-before
:after-load game.client.core/shadow-after}

:modules
{:client
{:entries [game.client.core]}
Expand Down
10 changes: 10 additions & 0 deletions src.client/game/client/core.cljs
Expand Up @@ -129,3 +129,13 @@
(new-page :not-found (page-not-found/new-page-not-found)))

(if (> @run-count 0) (main) (js/$ (main)))

(println "core")

(defn shadow-before
[]
(println "shadow-before"))

(defn shadow-after
[]
(println "shadow-after"))
9 changes: 6 additions & 3 deletions src/game/server/config.cljs
Expand Up @@ -13,9 +13,12 @@
(-> process .-env .-HOME))

(def jsconfig
(let
[config-data (-> js/global .-rtsconfig)]
(-> config-data (js->clj :keywordize-keys true))))
(or
(let
[config-data (-> js/global .-rtsconfig)]
(-> config-data (js->clj :keywordize-keys true)))
{
:production false}))

(println "config2" jsconfig)

Expand Down
6 changes: 3 additions & 3 deletions src/game/server/core.cljs
Expand Up @@ -65,11 +65,11 @@
(assoc :passport passport)
component/start)))

(defn -main
(defn main
[]
(println "Main")
(with-simple-cause #(swap! system component/stop-system))
(with-simple-cause #(swap! system component/start-system)))

(-main)
(set! *main-cli-fn* -main)
;(-main)
;(set! *main-cli-fn* -main)

0 comments on commit e117de2

Please sign in to comment.