Merge: Extends catalog with a *try it* and a *download apk* links
authorJean Privat <jean@pryen.org>
Wed, 16 Sep 2015 17:11:55 +0000 (13:11 -0400)
committerJean Privat <jean@pryen.org>
Wed, 16 Sep 2015 17:11:55 +0000 (13:11 -0400)
Two new package metadata are added

* `upstream.tryit` for an URL that points to a demo version or a live version of the main web service offered by the package.
* `upstream.apk` for an URL that points to a dry `apk`, or an install page on some store, for the main android application offered by the package.

Moreover, packages that have one them will be respectively tagged `tryit` and `apk`

A demo is available: http://info.uqam.ca/~privat/catalog/#tag_tryit and http://info.uqam.ca/~privat/catalog/#tag_apk

Pull-Request: #1724
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>

25 files changed:
benchmarks/.gitignore
benchmarks/Makefile [new file with mode: 0644]
benchmarks/bench_common.sh
benchmarks/bench_engines.sh
benchmarks/bench_languages.sh
benchmarks/bench_nitdoc.sh
benchmarks/bench_nitunit.sh
benchmarks/bench_plot.sh
benchmarks/markdown/Makefile
benchmarks/markdown/bench_markdown.sh
benchmarks/polygons/Makefile
benchmarks/polygons/nit/Makefile
benchmarks/polygons/nit/bench_polygon.sh
benchmarks/strings/Makefile
benchmarks/strings/bench_strings.sh
contrib/crazy_moles/Makefile
contrib/friendz/src/friendz.nit
contrib/friendz/src/grid.nit
contrib/friendz/src/level.nit
contrib/mnit_test/org.nitlanguage.test_minimal.txt [new file with mode: 0644]
contrib/tinks/net.xymus.tinks.txt [new file with mode: 0644]
examples/calculator/Makefile
examples/calculator/org.nitlanguage.calculator.txt [new file with mode: 0644]
lib/android/audio.nit
misc/jenkins/check_contrib.sh

index 43fa343..b6bd96d 100644 (file)
@@ -7,3 +7,5 @@ index.html
 nitc
 nitdoc
 nitdoc.*
+logs
+nit_compile
diff --git a/benchmarks/Makefile b/benchmarks/Makefile
new file mode 100644 (file)
index 0000000..6c62287
--- /dev/null
@@ -0,0 +1,5 @@
+all:
+       ./bench_engines.sh all
+
+check:
+       ./bench_engines.sh --fast --fast bench_nitc_options
index 4ea5ffe..207edd0 100644 (file)
@@ -94,3 +94,9 @@ function skip_test()
        return 1
 }
 
+# Helper function. Print the error message and set $died to 1
+function die()
+{
+       echo >&2 "error: $*"
+       died=1
+}
index b2534e7..37b2fb9 100755 (executable)
@@ -26,14 +26,6 @@ source ./bench_plot.sh
 # Can be overrided with 'the option -n'
 count=2
 
-### HELPER FUNCTIONS ##
-
-function die()
-{
-       echo >&2 "error: $*"
-       died=1
-}
-
 # HELPER FOR NIT #
 
 # Run standards benchs on a compiler command
@@ -93,7 +85,6 @@ function usage()
        echo "  -n count: number of execution for each bar (default: $count)"
        echo "  --dry: Do not run the commands, just reuse the data and generate the graph"
        echo "  --fast: Run less and faster tests"
-       echo "  --html: Generate and HTML output"
        echo "  -h: this help"
 }
 
@@ -105,11 +96,14 @@ while [ "$stop" = false ]; do
                -n) count="$2"; shift; shift;;
                --dry) dry_run=true; shift;;
                --fast) fast=true$fast; shift;;
-               --html) html="index.html"; echo >"$html" "<html><head></head><body>"; shift;;
+               --html) shift;; # Deprecated
                *) stop=true
        esac
 done
 
+html="index.html"
+echo >"$html" "<html><head></head><body>"
+
 xml="bench_engines.xml"
 echo "<testsuites><testsuite>" > "$xml"
 
@@ -195,12 +189,12 @@ function bench_nitc_options()
 
        for opt in "$@"; do
                ot=${opt// /}
-               prepare_res "$name$ot.dat" "$opt" "nitc-g with option $opt"
+               prepare_res "$name$ot.dat" "$opt" "nitc with option $opt"
                run_compiler "nitc-$name" ./nitc $common $opt
        done
 
        if test -n "$2" -a -n "$withall"; then
-               prepare_res "$name-all.dat" "all" "nitc-g with all options $@"
+               prepare_res "$name-all.dat" "all" "nitc with all options $@"
                run_compiler "nitc-$name" ./nitc $common $@
        fi
 
@@ -210,20 +204,22 @@ function bench_nitc_options()
 bench_nitc_options "slower" --global --hardening --no-shortcut-range
 bench_nitc_options "nocheck" --global --no-check-null --no-check-autocast --no-check-attr-isset --no-check-covariance --no-check-assert
 
-bench_nitc_options "slower" --separate --hardening --no-shortcut-equal --no-union-attribute --no-shortcut-range --no-inline-intern "--no-gcc-directive likely --no-gcc-directive noreturn" "--no-tag-primitives"
+bench_nitc_options "slower" --separate --hardening --no-shortcut-equal --no-union-attribute --no-shortcut-range --no-inline-intern "--no-gcc-directive likely --no-gcc-directive noreturn" "--no-tag-primitives" "--colo-dead-methods" --type-poset
 bench_nitc_options "nocheck" --separate --no-check-null --no-check-autocast --no-check-attr-isset --no-check-covariance --no-check-assert
 bench_nitc_options "faster" --separate --skip-dead-methods --inline-coloring-numbers --inline-some-methods --direct-call-monomorph "--inline-some-methods --direct-call-monomorph"
 
 bench_nitc_options "slower" --erasure --hardening --no-shortcut-equal --no-union-attribute --no-shortcut-range --no-inline-intern
-bench_nitc_options "nocheck" --erasure --no-check-null --no-check-autocast --no-check-attr-isset --no-check-covariance --no-check-assert --no-check-erasure-cast
+bench_nitc_options "nocheck" --erasure --no-check-null --no-check-autocast --no-check-attr-isset --no-check-covariance --no-check-assert --no-check-erasure-cast --no-check-all
 bench_nitc_options "faster" --erasure --skip-dead-methods --inline-coloring-numbers --inline-some-methods --direct-call-monomorph --rta
 
 bench_nitc_options "engine" "" NOALL "--separate" "--erasure" "--separate --semi-global" "--erasure --semi-global" "--erasure --semi-global --rta" "--global"
 bench_nitc_options "policy" "" NOALL "--separate" "--erasure" "--separate --no-check-covariance" "--erasure --no-check-covariance --no-check-erasure-cast"
 bench_nitc_options "nullables" "" "--no-check-attr-isset" "--no-union-attribute"
-bench_nitc_options "linkboost" "" NOALL --trampoline-call --colors-are-symbols "--colors-are-symbols --trampoline-call" "--separate --link-boost" "--separate --colors-are-symbols --guard-call" "--separate --colors-are-symbols --direct-call-monomorph0"
+bench_nitc_options "linkboost" "" NOALL --trampoline-call --colors-are-symbols "--colors-are-symbols --trampoline-call" "--separate --link-boost" "--separate --colors-are-symbols --guard-call" "--separate --colors-are-symbols --direct-call-monomorph0" "--substitute-monomorph"
 bench_nitc_options "monomorph" "" --direct-call-monomorph0 --direct-call-monomorph
 
+bench_nitc_options "misc" "" --log --typing-test-metrics --invocation-metrics --isset-checks-metrics --tables-metrics --no-stacktrace --release --debug #FIXME add --sloppy
+
 function bench_nitc-e_gc()
 {
        name="$FUNCNAME"
@@ -272,9 +268,7 @@ function bench_compilation_time
 }
 bench_compilation_time
 
-if test -n "$html"; then
-       echo >>"$html" "</body></html>"
-fi
+echo >>"$html" "</body></html>"
 
 echo >>"$xml" "</testsuite></testsuites>"
 
index 0e0b59a..2a33170 100755 (executable)
@@ -26,14 +26,6 @@ source ./bench_plot.sh
 # Can be overrided with 'the option -n'
 count=2
 
-### HELPER FUNCTIONS ##
-
-function die()
-{
-       echo >&2 "error: $*"
-       died=1
-}
-
 ## HANDLE OPTIONS ##
 
 function usage()
index 07613b2..4a1d2a7 100755 (executable)
@@ -24,14 +24,6 @@ source ./bench_plot.sh
 # Can be overrided with 'the option -n'
 count=3
 
-### HELPER FUNCTIONS ##
-
-function die()
-{
-       echo >&2 "error: $*"
-       died=1
-}
-
 ## HANDLE OPTIONS ##
 
 function usage()
index 53eb38c..23279f1 100755 (executable)
@@ -24,14 +24,6 @@ source ./bench_plot.sh
 # Can be overrided with 'the option -n'
 count=3
 
-### HELPER FUNCTIONS ##
-
-function die()
-{
-       echo >&2 "error: $*"
-       died=1
-}
-
 ## HANDLE OPTIONS ##
 
 function usage()
index e874308..08a13e6 100755 (executable)
@@ -103,7 +103,8 @@ if test -n "$html"; then
        echo gnuplot -e "set term png; set output \"$bn.png\"" "$1"
 
        echo >>"$html" "<img src=\"$bn.png\"/>"
-else
+fi
+if test -n "$DISPLAY"; then
        echo "# gnuplot -p $1"
        gnuplot -p "$1"
 fi
index 802fab6..ca25141 100644 (file)
@@ -15,6 +15,9 @@
 all:
        ./bench_markdown.sh all
 
+check:
+       ./bench_markdown.sh -s 1 nit
+
 clean:
        $(MAKE) clean -C benches
        $(MAKE) clean -C engines
index aaa34f0..485b944 100755 (executable)
@@ -24,13 +24,8 @@ source ../bench_plot.sh
 # Can be overrided with 'the option -n'
 count=2
 
-### HELPER FUNCTIONS ##
-
-function die()
-{
-       echo >&2 "error: $*"
-       died=1
-}
+# Default number of times the input file is transformed during a single run
+s=200
 
 ## HANDLE OPTIONS ##
 
@@ -39,6 +34,7 @@ function usage()
        echo "run_bench: [options]* benchname"
        echo "  -v: verbose mode"
        echo "  -n count: number of execution for each bar (default: $count)"
+       echo "  -s size: number of transformations for each run (default: $s)"
        echo "  --dry: Do not run the commands, just reuse the data and generate the graph"
        echo "  -h: this help"
 }
@@ -49,6 +45,7 @@ while [ "$stop" = false ]; do
                -v) verbose=true; shift;;
                -h) usage; exit;;
                -n) count="$2"; shift; shift;;
+               -s) s="$2"; shift; shift;;
                --dry) dry_run=true; shift;;
                *) stop=true
        esac
@@ -73,8 +70,8 @@ outdir="./out"
 engdir="./engines"
 bncdir="./benches/out"
 mkdir -p $outdir
-
-s=200
+html="index.html"
+echo >"$html" "<html><head></head><body>"
 
 function bench_nitmd()
 {
@@ -140,6 +137,8 @@ if test "$#" -gt 0; then
     plot $outdir/bench_markdown.gnu
 fi
 
+echo >>"$html" "</body></html>"
+
 if test -n "$died"; then
        echo "Some commands failed"
        exit 1
index e6bd303..f7d0763 100644 (file)
@@ -1,3 +1,6 @@
 all:
        $(MAKE) all -C nit
        $(MAKE) all -C java
+
+check:
+       $(MAKE) check -C nit
index e327368..71dffea 100644 (file)
@@ -17,3 +17,11 @@ convexity_b:
 
 contain_b:
        ./bench_polygon.sh contain
+
+check:
+       ./bench_polygon.sh -p 100 add_vertex
+       ./bench_polygon.sh -p 100 sort_vertices
+       ./bench_polygon.sh -p 100 intersection
+       ./bench_polygon.sh -p 100 convex_hull
+       ./bench_polygon.sh -p 100 convexity
+       ./bench_polygon.sh -p 100 contain
index 52895e9..8b7fc08 100755 (executable)
@@ -166,3 +166,9 @@ case "$1" in
        contain) shift; bench_contain $@;;
        *) usage; exit;;
 esac
+
+if test -n "$died"; then
+       echo "Some commands failed"
+       exit 1
+fi
+exit 0
index 3717681..2453d1b 100644 (file)
@@ -12,6 +12,8 @@ iter:
 index:
        ./bench_strings.sh index 10000000 50 25 200
 
+check: basic
+
 basic:
        ./bench_strings.sh basic
 
index 7a09065..5d24653 100755 (executable)
@@ -205,14 +205,14 @@ function launch_bench()
        echo "  Trying variant $variant for benchmark $bench"
        echo "---------------------------------------------------------"
        git diff-index --quiet HEAD || {
-               echo "Cannot run benches on a dirty working directory."
-               echo "Please commit or stash your modifications and relaunch the command."
-               exit 1
+               die "Cannot run benches on a dirty working directory."
+               die "Please commit or stash your modifications and relaunch the command."
+               return
        }
        git am $curr_rev || {
-               echo "Error when applying patch $curr_rev"
-               git am --abort;
-               exit 1;
+               die "Error when applying patch $curr_rev"
+               git am --abort
+               return
        }
        if [ "$need_bootstrap" = true ]; then
                prepare_compiler
@@ -263,12 +263,6 @@ function main()
        bench=$1
        shift;
 
-       git diff-index --quiet HEAD || {
-               echo "Cannot run benches on a dirty working directory."
-               echo "Please commit or stash your modifications and relaunch the command."
-               exit 1
-       }
-
        head=`git rev-parse HEAD`
        variant="HEAD"
        need_plot=true
@@ -314,3 +308,9 @@ function main()
 }
 
 main "$@";
+
+if test -n "$died"; then
+       echo "Some commands failed"
+       exit 1
+fi
+exit 0
index 049e851..113329d 100644 (file)
@@ -1,3 +1,7 @@
+
+SVG2ICONS=../inkscape_tools/bin/svg_to_icons
+SVG2PNG=../inkscape_tools/bin/svg_to_png_and_nit
+
 default: bin/moles
 
 bin/moles: $(shell ../../bin/nitls -M src/moles_linux.nit) assets/images/drawing.png
@@ -13,19 +17,19 @@ android-release: android-icons $(shell ../../bin/nitls -M src/moles_android.nit)
        mkdir -p bin
        ../../bin/nitc -o bin/moles.apk src/moles_android.nit --release
 
-../inkscape_tools/bin/svg_to_icons:
+$(SVG2ICONS):
        $(MAKE) -C ../inkscape_tools
 
-android-icons: ../../contrib/inkscape_tools/bin/svg_to_icons art/icon.svg
+android-icons: $(SVG2ICONS) art/icon.svg
        mkdir -p res
-       ../inkscape_tools/bin/svg_to_icons art/icon.svg --android --out res/
+       $(SVG2ICONS) art/icon.svg --android --out res/
 
 android-install: bin/moles.apk
        adb install -rf bin/moles.apk
 
-assets/images/drawing.png: art/drawing.svg ../../contrib/inkscape_tools/bin/svg_to_icons
+assets/images/drawing.png: art/drawing.svg $(SVG2ICONS)
        mkdir -p assets/images
-       ../inkscape_tools/bin/svg_to_png_and_nit --src src/ --scale 2.0 art/drawing.svg
+       $(SVG2PNG) --src src/ --scale 2.0 art/drawing.svg
 
 check-android: bin/moles.apk
        ../../misc/jenkins/check_android.sh bin/moles.apk
index 9425abe..c0554fe 100644 (file)
@@ -19,7 +19,6 @@ import realtime
 import solver
 import mnit::tileset
 import app::data_store
-import md5
 
 intrude import grid
 intrude import level
@@ -217,11 +216,11 @@ class LevelButton
 
                self.over = self.level.fullname
                if self.level.get_state >= l.l_won then
-                       if game.levels[9].get_state >= l.l_won then self.over += " --- {self.level.score}/{self.level.par}"
+                       if game.levels[9].get_state >= l.l_won then self.over += " --- {self.level.score}/{self.level.gold}"
                else if self.level.get_state >= l.l_open then
-                       if game.levels[9].get_state >= l.l_open then self.over +=  " --- ?/{self.level.par}"
+                       if game.levels[9].get_state >= l.l_open then self.over +=  " --- ?/{self.level.gold}"
                end
-               #self.enabled = l.get_state >= l.l_open
+               self.enabled = l.get_state >= l.l_open or game.cheated
        end
 
        redef fun draw(ctx)
@@ -242,7 +241,7 @@ class LevelButton
                end
                ctx.blit(game.img[ix,iy], self.x, self.y)
 
-               if s == l.l_par then
+               if s == l.l_gold then
                        ctx.blit(game.img2[7,0], self.x + bw*5/8, self.y-bh*1/8)
                end
                ctx.textx(self.level.name, self.x+5, self.y+5, 24, null, null)
@@ -730,9 +729,9 @@ class Score
                end
                if game.levels[9].get_state >= level.l_won then
                        if level.is_challenge then
-                               ctx.textx("GOAL: {level.par}",self.x,self.y+44,21,"yellow",null)
+                               ctx.textx("GOAL: {level.gold}",self.x,self.y+44,21,"yellow",null)
                        else
-                               ctx.textx("PAR: {level.par}",self.x,self.y+44,21,"yellow",null)
+                               ctx.textx("GOLD: {level.gold}",self.x,self.y+44,21,"yellow",null)
                        end
                end
        end
@@ -777,7 +776,7 @@ class StatusBar
        do
                print "***STATUS** {txt}"
                self.tmp_txt = txt
-               self.tmp_txt_ttl = 20
+               self.tmp_txt_ttl = 60
                self.tmp_txt_color = color
        end
 
@@ -873,26 +872,6 @@ redef class Game
        # Font
        var font = new TileSetFont(app.load_image("deltaforce_font.png"), 16, 17, "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789.:;!?\"'() -,/")
 
-       var xxx = """
-       fun save_cookie(name, val:String) do
-       var days = 365
-       var date = new Date()
-       date.setTime(date.getTime()+(days*24*60*60*1000))
-       document.cookie = name+"="+val+"; expires="+date.toGMTString()+"; path=/"
-       end
-
-       fun read_cookie(name:String):String do
-       var key = name + "="
-       var ca = document.cookie.split(';')
-       for(var i=0; i<ca.length; i++) do
-       var c = ca[i]
-       while (c[0]==' ') c = c.substring(1, c.length)
-       if (c.indexOf(key) == 0) return c.substring(key.length)
-       end
-       return null
-       end
-       """
-
        # DISPLAY *****************************************************************
 
        # Is the game in editing mode
@@ -904,10 +883,10 @@ redef class Game
        # SOUND
 
        # Is the music muted?
-       var music_muted: Bool = false #read_cookie("music_muted")
+       var music_muted: Bool = app.data_store["music_muted"] == true
 
        # Is the sound effects muted?
-       var sfx_muted: Bool = false #read_cookie("sfx_muted")
+       var sfx_muted: Bool = app.data_store["sfx_muted"] == true
 
        # The background music resource. */
        var music = new Music("music.ogg")
@@ -957,12 +936,16 @@ redef class Game
        # ResizeButton
        var button_size = new ResizeButton(self)
 
+       # Cheat mode enabled?
+       var cheated = false
+
        init
        do
-               load_levels
                init_buttons
                entities.clear
                title
+
+               if not music_muted then music.play
        end
 
        # fill `buttons`
@@ -976,8 +959,9 @@ redef class Game
        # Play a level in player mode.
        fun play(l: Level)
        do
+               save # save the previous level grid
                level = l
-               grid.load(level.str)
+               grid.load(level.saved_str or else level.str)
                init_play_menu(false)
                if level.status != "" then
                        statusbar.main_txt = level.status
@@ -1071,6 +1055,7 @@ redef class Game
        # Helper function to initialize the menu (and tile) screen
        fun init_menu
        do
+               save # save the previous level grid
                init_game
                level = null
                var i = levels.first
@@ -1094,7 +1079,7 @@ redef class Game
                end
                t = new Achievement(self, 0, "Training")
                entities.push(t)
-               t = new Achievement(self, 1, "Par")
+               t = new Achievement(self, 1, "Gold")
                entities.push(t)
                t = new Achievement(self, 2, "Editor")
                entities.push(t)
@@ -1225,8 +1210,19 @@ redef class Game
        fun onKeyDown(ev: Event) do
                var kc = ev.char_code
                if kc == "e" then
+                       set_tmp("RUN EDITOR")
                        grid_edit = grid.copy(true)
                        edit_grid(grid)
+               else if kc == "c" then
+                       if cheated then
+                               set_tmp("CHEAT: OFF")
+                               snd_duh.play
+                               cheated = false
+                       else
+                               set_tmp("CHEAT: ON")
+                               snd_win.play
+                               cheated = true
+                       end
                else if kc == "s" then
                        if solver == null then
                                solver = (new FriendzProblem(grid)).solve
@@ -1234,20 +1230,28 @@ redef class Game
                        else
                                solver_pause = not solver_pause
                        end
+                       if solver_pause then
+                               set_tmp("SOLVER: PAUSED")
+                       else
+                               set_tmp("SOLVER: ON")
+                       end
                        #solver.step
                else if kc == "d" then
                        if solver == null then
                                solver = (new FriendzProblem(grid)).solve
                                solver_pause = true
+                               set_tmp("SOLVER: ON")
                        else
+                               solver_pause = true
                                solver.run_steps(1)
+                               set_tmp("SOLVER: ONE STEP")
                        end
                else if kc == "+" then
                        solver_steps += 100
-                       print solver_steps
+                       set_tmp("SOLVER: {solver_steps} STEPS")
                else if kc == "-" then
                        solver_steps -= 100
-                       print solver_steps
+                       set_tmp("SOLVER: {solver_steps} STEPS")
                else for g in entities do
                        if kc == g.shortcut then
                                g.click(ev)
@@ -1256,15 +1260,33 @@ redef class Game
                end
        end
 
+       fun set_tmp(s: String)
+       do
+               statusbar.set_tmp(s, "cyan")
+       end
+
        redef fun load_levels
        do
                super
 
                for level in levels do
-                       var score = app.data_store["s{level.str.md5}"]
+                       var score = app.data_store["s{level.str}"]
                        if score isa Int then
                                level.score = score
                        end
+                       var saved_str = app.data_store["g{level.str}"]
+                       if saved_str isa String then
+                               print "LOAD {level.name}: {saved_str}"
+                               level.saved_str = saved_str
+                       end
+               end
+       end
+
+       fun save
+       do
+               var l = level
+               if l != null then
+                       l.save
                end
        end
 end
@@ -1359,12 +1381,13 @@ class MusicButton
        init(game: Game)
        do
                super(game, "MUSIC", 470, 412, "purple", "Mute the music", "Unmute the music")
+               toggled = game.music_muted
        end
        redef fun click2(ev)
        do
                game.music_muted = self.toggled
                if game.music_muted then game.music.pause else game.music.play
-               #game.save_cookie("music_muted",music_muted?"true":"")
+               app.data_store["music_muted"] = game.music_muted
        end
 end
 
@@ -1373,13 +1396,14 @@ class SFXButton
        init(game: Game)
        do
                super(game, "SOUND FX", 470, 382, "purple", "Mute the sound effects", "Unmute the sound effects")
+               toggled = game.sfx_muted
        end
 
        redef fun click2(ev)
        do
                game.sfx_muted = self.toggled
                if not game.sfx_muted then game.snd_whip.play # Because the automatic one was muted
-               #save_cookie("sfx_muted",sfx_muted?"true":"")
+               app.data_store["sfx_muted"] = game.sfx_muted
        end
 end
 
@@ -1579,6 +1603,12 @@ redef class App
                # img loading?
        end
 
+       redef fun on_pause
+       do
+               super
+               game.save
+       end
+
        # Maximum wanted frame per second
        var max_fps = 30
 
@@ -1636,8 +1666,16 @@ redef class KeyEvent
 end
 
 redef class Level
-       redef fun save
+       # Save the score and grid of the level
+       fun save
        do
-               app.data_store["s{str.md5}"] = if score > 0 then score else null
+               app.data_store["s{str}"] = if score > 0 then score else null
+               var saved = game.grid.save
+               saved_str = saved
+               app.data_store["g{str}"] = saved
+               print "SAVE: {name}: {saved}"
        end
+
+       # The saved player grid (to continue games)
+       var saved_str: nullable String = null
 end
index a097ff5..3a141f6 100644 (file)
@@ -191,14 +191,14 @@ class Grid
        fun save: String
        do
                var res = ""
-               var str = ".#ABCDEFGHI"
+               var str = ".abcdefghi#ABCDEFGHI"
                for y in [0..height[ do
                        var rle = 0
                        var last: nullable Int = null
                        for x in [0..width[ do
                                var t = self.grid[x][y]
-                               var tk = 0
-                               if t.fixed then tk = t.kind + 1
+                               var tk = t.kind
+                               if t.fixed then tk += 10
                                if tk == last and rle<9 then
                                        rle += 1
                                else
@@ -243,6 +243,7 @@ class Grid
                                        x += 1
                                else if c == '#' then
                                        var t = self.get(x,y)
+                                       assert t != null
                                        t.fixed = true
                                        x += 1
                                else if c >= 'A' and c <= 'I' then
@@ -251,6 +252,11 @@ class Grid
                                        t.update(c.ascii-'A'.ascii+1)
                                        t.fixed = true
                                        x += 1
+                               else if c >= 'a' and c <= 'i' then
+                                       var t = self.get(x,y)
+                                       assert t != null
+                                       t.update(c.ascii-'a'.ascii+1)
+                                       x += 1
                                else if c >= '1' and c <= '9' then
                                        rle = c.to_i
                                else
@@ -261,7 +267,7 @@ class Grid
                if x>0 then y += 1
                if x > mx then mx = x
                if y > my then my = y
-               if mx<3 or my<3 or mx>=max_width or my>=max_height then
+               if mx<3 or my<3 or mx>max_width or my>max_height then
                        return false
                end
                self.resize(mx,my)
index 9d8029e..b09f1f2 100644 (file)
@@ -23,7 +23,7 @@ class Level
                var ls = code.split(";")
                self.number = i
                self.str = ls[0]
-               self.par = ls[1].to_i
+               self.gold = ls[1].to_i
                if ls.length >= 3 then
                        self.status = ls[2]
                end
@@ -47,8 +47,8 @@ class Level
        # initial grid position
        var str: String
 
-       # top score
-       var par: Int
+       # top score to get gold
+       var gold: Int
 
        # Help message if any
        var status: String = ""
@@ -72,32 +72,28 @@ class Level
        var l_disabled = 1
        var l_open = 2
        var l_won = 3
-       var l_par = 4
+       var l_gold = 4
 
        fun get_state: Int
        do
                if self.score == 0 then
                        if self.number == 0 or game.levels[self.number-1].score > 0 then return l_open
                        if self.number == 25 and game.levels[19].score > 0 then return l_open else return l_disabled
-               else if self.score < self.par or not game.levels[9].score > 0 then
+               else if self.score < self.gold or not game.levels[9].score > 0 then
                        return l_won
-               else return l_par
+               else return l_gold
        end
 
        # Returns true if g is a wining condition for the level.
        fun check_won(g: Grid): Bool
        do
-               var w = g.won and (not self.is_challenge or g.number >= self.par)
+               var w = g.won and (not self.is_challenge or g.number >= self.gold)
                if not w then return false
                if g.number > self.score then
                        self.score = g.number
-                       self.save
                end
                return true
        end
-
-       # Save the score of the level
-       fun save do end
 end
 
 # main game object
diff --git a/contrib/mnit_test/org.nitlanguage.test_minimal.txt b/contrib/mnit_test/org.nitlanguage.test_minimal.txt
new file mode 100644 (file)
index 0000000..9f3bb3c
--- /dev/null
@@ -0,0 +1,10 @@
+Categories:Nit
+License:Apache2
+Web Site:http://nitlanguage.org
+Source Code:http://nitlanguage.org/nit.git/tree/HEAD:/contrib/mnit_test
+Issue Tracker:https://github.com/nitlang/nit/issues
+
+Summary:Minimal Demo for MNit
+Description:
+A useless application that test various basic API usage of the mnit framework on Android.
+.
diff --git a/contrib/tinks/net.xymus.tinks.txt b/contrib/tinks/net.xymus.tinks.txt
new file mode 100644 (file)
index 0000000..ceed2bc
--- /dev/null
@@ -0,0 +1,13 @@
+Categories:Nit,Games
+License:Apache2
+Web Site:http://nitlanguage.org
+Source Code:http://nitlanguage.org/nit.git/tree/HEAD:/contrib/tinks
+Issue Tracker:https://github.com/nitlang/nit/issues
+
+Summary:Multiplayer crossplatform action game with destructible procedurally generated worlds
+Description:
+Each player controls a tank, opens fire from the turret and navigates between the terrain features.
+Explosions from turret fire and tank destruction have different forces and destroy the terrain.
+Each tank needs 4 hits to be destroyed.
+Destroyed tanks drop health power-ups which can repair other tanks.
+.
index edcfc14..24b10ab 100644 (file)
@@ -1,17 +1,26 @@
 NITC=../../bin/nitc
 NITLS=../../bin/nitls
 
-all: bin/calculator bin/calculator.apk bin/test
+all: bin/calculator bin/test
 
 bin/calculator: $(shell ${NITLS} -M src/calculator.nit -m linux) ${NITC}
        mkdir -p bin
        ${NITC} -o $@ src/calculator.nit -m linux
 
-bin/calculator.apk: $(shell ${NITLS} -M src/calculator.nit -m android) ${NITC} ../../contrib/inkscape_tools/bin/svg_to_icons
-       mkdir -p bin res
-       ../../contrib/inkscape_tools/bin/svg_to_icons art/icon.svg --android --out res/
+android: bin/calculator.apk
+
+bin/calculator.apk: $(shell ${NITLS} -M src/calculator.nit -m android) ${NITC} res/drawable-ldpi/icon.png
+       mkdir -p bin
        ${NITC} -o $@ src/calculator.nit -m ../../lib/android/ui/ -D debug
 
+android-release: $(shell ${NITLS} -M src/calculator.nit -m android) ${NITC} res/drawable-ldpi/icon.png
+       mkdir -p bin
+       ${NITC} -o bin/calculator.apk src/calculator.nit -m ../../lib/android/ui/ --release
+
+res/drawable-ldpi/icon.png: art/icon.svg ../../contrib/inkscape_tools/bin/svg_to_icons
+       mkdir -p res
+       ../../contrib/inkscape_tools/bin/svg_to_icons art/icon.svg --android --out res/
+
 ../../contrib/inkscape_tools/bin/svg_to_icons:
        make -C ../../contrib/inkscape_tools/
 
diff --git a/examples/calculator/org.nitlanguage.calculator.txt b/examples/calculator/org.nitlanguage.calculator.txt
new file mode 100644 (file)
index 0000000..264d18b
--- /dev/null
@@ -0,0 +1,12 @@
+Categories:Nit
+License:Apache2
+Web Site:http://nitlanguage.org
+Source Code:http://nitlanguage.org/nit.git/tree/HEAD:/examples/calculator
+Issue Tracker:https://github.com/nitlang/nit/issues
+
+Summary:A Basic Calculator
+Description:
+10 digits, 4 operations, hours of fun.
+
+This is the official example of a portable GUI application built using app.nit.
+.
index b361b4f..9cc54d7 100644 (file)
@@ -377,6 +377,16 @@ class MediaPlayer
 
        # Load a sound for a given resource id
        fun load_sound(id: Int, context: NativeActivity): Music do
+               # FIXME: maybe find a better way to handle this situation
+               # If two different music are loaded with the same `MediaPlayer`,
+               # a new `NativeMediaPlayer` will be created for the secondd music
+               # and the nit program will loose the handle to the previous one
+               # If the previous music is playing, we need to stop it
+               if playing then
+                       stop
+                       reset
+                       destroy
+               end
                self.nmedia_player = self.nmedia_player.create(context, id)
                if self.nmedia_player.is_java_null then
                        self.error = new Error("Failed to load a sound")
@@ -482,6 +492,10 @@ class MediaPlayer
 end
 
 redef class PlayableAudio
+       # Flag to know if the user paused the sound
+       # Used when the app pause all sounds or resume all sounds
+       var paused: Bool = false
+
        redef init do add_to_sounds(self)
 end
 
@@ -544,11 +558,13 @@ redef class Sound
        redef fun pause do
                if self.error != null or not self.is_loaded then return
                soundpool.pause_stream(soundpool_id)
+               paused = true
        end
 
        redef fun resume do
                if self.error != null or not self.is_loaded then return
                soundpool.resume(soundpool_id)
+               paused = false
        end
 
 end
@@ -606,11 +622,13 @@ redef class Music
        redef fun pause do
                if self.error != null or not self.is_loaded then return
                media_player.pause
+               paused = true
        end
 
        redef fun resume do
                if self.error != null or not self.is_loaded then return
                play
+               paused = false
        end
 end
 
@@ -674,7 +692,16 @@ redef class App
 
        redef fun on_pause do
                super
-               for s in sounds do s.pause
+               for s in sounds do
+                       # Pausing sounds that are not already paused by user
+                       # `s.paused` is set to false because `pause` set it to true
+                       # and we want to know which sound has been paused by the user
+                       # and which one has been paused by the app
+                       if not s.paused then
+                               s.pause
+                               s.paused = false
+                       end
+               end
                audio_manager.abandon_audio_focus
        end
 
@@ -687,7 +714,10 @@ redef class App
        redef fun on_resume do
                super
                audio_manager.request_audio_focus
-               for s in sounds do s.resume
+               for s in sounds do
+                       # Resumes only the sounds paused by the App
+                       if not s.paused then s.resume
+               end
        end
 end
 
index fafeb92..df81660 100755 (executable)
@@ -29,19 +29,22 @@ failed=
 for p in $projects; do
        dir=`dirname "$p"`
        name=`basename "$dir"`
-       echo "*** make $dir ***"
-       if misc/jenkins/unitrun.sh "cmd-$name-make" make -C "$dir"; then
-               # Make OK. Check additional rules if they exists
-               for rule in $rules; do
-                       make -C "$dir" $rule -n 2>/dev/null ||
-                               continue
-                       echo "*** make$rule $dir ***"
-                       misc/jenkins/unitrun.sh "cmd-$name-make$rule" make -C "$dir" $rule ||
-                               failed="$failed $name-$rule"
-               done
-       else
-               failed="$failed $name"
-       fi
+       echo "### in $dir ###"
+       # Check each rules, if they exists
+       for rule in $rules; do
+               make -C "$dir" $rule -n >/dev/null 2>/dev/null || {
+                       # Special case for `all` that falls back as the default target
+                       if [ "$rule" = "all" ]; then
+                               echo "*** make -C $dir ***"
+                               misc/jenkins/unitrun.sh "cmd-$name-make" make -C "$dir" ||
+                                       failed="$failed $name"
+                       fi
+                       continue
+               }
+               echo "*** make $rule -C $dir ***"
+               misc/jenkins/unitrun.sh "cmd-$name-make$rule" make -C "$dir" $rule ||
+                       failed="$failed $name-$rule"
+       done
 done
 grep '<error message' *-make*.xml
 if test -n "$failed"; then