nit.git
6 years agogamnit: add an example to showcase fonts support
Alexis Laferrière [Tue, 13 Jun 2017 14:36:02 +0000 (10:36 -0400)]
gamnit: add an example to showcase fonts support

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: implement new `TextSprites` settings in `BMFont`
Alexis Laferrière [Wed, 14 Jun 2017 13:35:16 +0000 (09:35 -0400)]
gamnit: implement new `TextSprites` settings in `BMFont`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: add customization settings to `TextSprites`
Alexis Laferrière [Tue, 13 Jun 2017 14:34:58 +0000 (10:34 -0400)]
gamnit: add customization settings to `TextSprites`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: fix actually using the attribute partial_line_skip
Alexis Laferrière [Tue, 13 Jun 2017 11:50:59 +0000 (07:50 -0400)]
gamnit: fix actually using the attribute partial_line_skip

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: accept float values in `BMFont`
Alexis Laferrière [Mon, 12 Jun 2017 20:26:40 +0000 (16:26 -0400)]
gamnit: accept float values in `BMFont`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: intro `CustomTexture::fill`
Alexis Laferrière [Wed, 14 Jun 2017 01:52:23 +0000 (21:52 -0400)]
gamnit: intro `CustomTexture::fill`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: move `pixelated=` up to `Texture`
Alexis Laferrière [Sat, 10 Jun 2017 18:39:45 +0000 (14:39 -0400)]
gamnit: move `pixelated=` up to `Texture`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: intro custom textures, built programmatically pixel per pixel
Alexis Laferrière [Sun, 11 Jun 2017 02:54:06 +0000 (22:54 -0400)]
gamnit: intro custom textures, built programmatically pixel per pixel

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: if a texture fails to load, use the checker texture
Alexis Laferrière [Fri, 9 Jun 2017 14:48:09 +0000 (10:48 -0400)]
gamnit: if a texture fails to load, use the checker texture

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: CheckerTexture with custom size and move up implementation
Alexis Laferrière [Fri, 9 Jun 2017 14:47:46 +0000 (10:47 -0400)]
gamnit: CheckerTexture with custom size and move up implementation

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agoMerge: gamnit: fix README and docker latest-full references to the use of SDL2 mixer
Jean Privat [Thu, 8 Jun 2017 20:01:29 +0000 (16:01 -0400)]
Merge: gamnit: fix README and docker latest-full references to the use of SDL2 mixer

Update gamnit README and latest-full docker for #2466.

Pull-Request: #2481

6 years agoMerge: lib/meta: add a *goret* approach to get the name of random types.
Jean Privat [Thu, 8 Jun 2017 20:01:05 +0000 (16:01 -0400)]
Merge: lib/meta: add a *goret* approach to get the name of random types.

may be used to improve deserialization?

Pull-Request: #2482
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

6 years agolib/meta: add a *goret* approach to get the name of random types.
Jean Privat [Thu, 8 Jun 2017 18:14:48 +0000 (14:14 -0400)]
lib/meta: add a *goret* approach to get the name of random types.

may be used to improve deserialization?

Signed-off-by: Jean Privat <jean@pryen.org>

6 years agodocker full: install missing package for SDL2 mixer
Alexis Laferrière [Thu, 8 Jun 2017 16:27:42 +0000 (12:27 -0400)]
docker full: install missing package for SDL2 mixer

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: don't recommend to install a package that is not used anymore
Alexis Laferrière [Thu, 8 Jun 2017 16:27:10 +0000 (12:27 -0400)]
gamnit: don't recommend to install a package that is not used anymore

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agoMerge: nitin: use GPL-3.0 instead of GPL-3
Jean Privat [Wed, 7 Jun 2017 20:11:11 +0000 (16:11 -0400)]
Merge: nitin: use GPL-3.0 instead of GPL-3

the tag is used to fill the catalog, http://nitlanguage.org/catalog/p/nitin.html but the link is broken whereas https://opensource.org/licenses/GPL-3.0 works

Signed-off-by: Jean Privat <jean@pryen.org>

Pull-Request: #2476

6 years agoMerge: listfull.sh: Quote paths
Jean Privat [Wed, 7 Jun 2017 20:11:10 +0000 (16:11 -0400)]
Merge: listfull.sh: Quote paths

Make the list unambiguous and easy to consume by POSIX shell scripts.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2473
Reviewed-by: Jean Privat <jean@pryen.org>

6 years agoMerge: modelbuilder_base: Refactor the signature of `resolve_mtype*`
Jean Privat [Wed, 7 Jun 2017 20:11:09 +0000 (16:11 -0400)]
Merge: modelbuilder_base: Refactor the signature of `resolve_mtype*`

Only `modelize_mclass` require support for partial context. Furthermore, in
a future PR, it may need to resolve types just before modeling the class
definition (in a place where the `MClass` is available and must be used).

Also include various related cleanups.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2472

6 years agoMerge: gamnit: Blinn-Phong specular lighting, 3 axes of rotation and more
Jean Privat [Wed, 7 Jun 2017 20:11:08 +0000 (16:11 -0400)]
Merge: gamnit: Blinn-Phong specular lighting, 3 axes of rotation and more

Implement a Blinn-Phong specular lighting shader to replace the previous Lamber diffuse lighting. It creates a reflection effect either from `specular_color` (as on the shields) or `specular_texture` (as on the gold tower).

![screenshot from 2017-05-31 10 16 13](https://cloud.githubusercontent.com/assets/208057/26636318/5a017ffc-45ea-11e7-8571-0918f13f6d9c.png)
![screenshot from 2017-05-30 23 13 32](https://cloud.githubusercontent.com/assets/208057/26636316/59c940c4-45ea-11e7-9106-99f9344cecbf.png)

The required material attributes for the specular effect were already present but not implemented. This PR adds similar attributes for normal maps, but leave them as a TODO. The new shader is fine but not optimal, I'll probably need to rewrite it to gain some performance, support normal maps and improve normals per vertex.

Add two angles of rotation to actors for full 3D rotation with Euler angles. All rotation angles follow the right-hand rule and are consistent between the camera and actors.

Other changes:
* Intro `Cuboid` that can be created by `Boxed3d::to_mesh`.
* Better error management when loading models.
* Fix missing `lock_cursor` implementation on desktop. It allows creating FPS like cameras.
* Fix and update `angle_lerp` to follow the style of `lerp` (where `self` is the weight).
* Improve the template project so 3D objects don't blend in the background and explain the printed performance statistics.

In a future PR, I'll standardize the assets classes and move some service up to `Asset`. This would allow for easier loading of all assets at once, no matter their type, and offer a standard behavior regarding errors and lazy loading.

Pull-Request: #2471
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

6 years agoMerge: Wrapper gmp
Jean Privat [Wed, 7 Jun 2017 20:11:06 +0000 (16:11 -0400)]
Merge: Wrapper gmp

gmp: Initial implementation of the GMP wrapper and simple test for it.

Pull-Request: #2460
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

6 years agoMerge: lib/core: introduce replace_first in text/string_search
Jean Privat [Tue, 6 Jun 2017 16:01:39 +0000 (12:01 -0400)]
Merge: lib/core: introduce replace_first in text/string_search

Replace the first occurrence of `pattern` with `string`

~~~nit
assert "hlelo".replace_first("le", "el") == "hello"
assert "hello".replace_first('l', "")    == "helo"
~~~

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

Pull-Request: #2475

6 years agoMerge: gamnit::network: add server discovery via UDP
Jean Privat [Tue, 6 Jun 2017 15:48:00 +0000 (11:48 -0400)]
Merge: gamnit::network: add server discovery via UDP

Move server discovery logic from Tinks! up to `gamnit::network` and extend existing services with more options. These new services allow for an easy discovery of local servers over UDP, as in the following example which also creates a server if none is found:

~~~nit
import gamnit::network

# Discover local servers
var servers = discover_local_servers
if servers.not_empty then
# Try to connect to the first local server
var server_info = servers.first
var server = new RemoteServer(server_info)

if not server.connect then
print_error "Failed to connect to {server_info.address}:{server_info.port}"
else if not server.handshake then
print_error "Failed handshake with {server_info.address}:{server_info.port}"
else
# Connected!
print "Connected to {server_info.address}:{server_info.port}"

# Write something and close connection
server.writer.serialize "hello server"
server.socket.as(not null).close
end
else
# Create a local server
var connect_port = 38271
print "Launching server: connect on {connect_port}, discovery on {discovery_port}"
var server = new Server(connect_port)

# Don't loop if testing
if "NIT_TESTING".environ == "true" then exit 0

loop
# Respond to discovery requests
server.answer_discovery_requests

# Accept new clients
var new_clients = server.accept_clients
for client in new_clients do
# Read something and close connection
assert client.reader.deserialize == "hello server"
client.socket.close
end
end
end
~~~

Pull-Request: #2470
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

6 years agoMerge: parser_nodes: Fix spelling mistakes
Jean Privat [Tue, 6 Jun 2017 15:45:44 +0000 (11:45 -0400)]
Merge: parser_nodes: Fix spelling mistakes

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2468
Reviewed-by: Jean Privat <jean@pryen.org>

6 years agoMerge: modelize_class: Remove the `useless-bound` warning
Jean Privat [Tue, 6 Jun 2017 15:44:52 +0000 (11:44 -0400)]
Merge: modelize_class: Remove the `useless-bound` warning

With class subsets, there is no bound that is useless.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2467

6 years agoMerge: popcorn: some useful services for JSON related REST API
Jean Privat [Tue, 6 Jun 2017 15:44:08 +0000 (11:44 -0400)]
Merge: popcorn: some useful services for JSON related REST API

This PR introduces a way to validate and deserialize requests bodies with some shortcuts.

I'm not a big fan of the `new_body_object` but I don't see how to do this elegantly...

~~~nit
class MyJsonHandler
  super Handler

  # Validator used do validate the body
  redef var validator = new MyFormValidator

  # Define the kind of objects expected by the deserialization process
  redef type BODY: MyForm

  # Instanciate the object from a deserializer
  redef fun new_body_object(d) do return new MyForm.from_deserializer(d)

  redef fun post(req, res) do
      var post = validate_body(req, res)
      if post == null then return # Validation error: let popcorn return a HTTP 400
      var form = deserialize_body(req, res)
      if form == null then return # Deserialization error: let popcorn return a HTTP 400

      # TODO do something with the input
      print form.name
  end
end

class MyForm
  serialize

  var name: String
end

class MyFormValidator
  super ObjectValidator

  init do
      add new StringField("name", min_size=1, max_size=255)
  end
end
~~~

Also, I moved json related services to this module and updated the clients.

Pull-Request: #2465
Reviewed-by: Jean Privat <jean@pryen.org>

6 years agoMerge: model: Remove truthful conditions
Jean Privat [Tue, 6 Jun 2017 15:39:54 +0000 (11:39 -0400)]
Merge: model: Remove truthful conditions

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2442
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agoMerge: Actors upgrade and fixes
Jean Privat [Tue, 6 Jun 2017 15:37:33 +0000 (11:37 -0400)]
Merge: Actors upgrade and fixes

`BlockingQueue` and `ReverseBlockingQueue` classes have been removed from  `lib/actors`  and are now in `lib/pthreads/concurrent_collections` because it's a better fit for them.
Also, since the implementation of `BlockingQueue` was too coupled with actors, the actor-specific implementation was kept in `lib/actors` and renamed as `Mailbox`.

`ReverseBlockingQueue` is a fun name and could be useful for some specific cases (as it was used in `lib/actors` or for synchronization on a list of dynamic tasks for example), but was too heavy for it's purpose in the `lib/actors` module. It's been replaced with a `SynchronizedCounter`. The `wait` method of this counter is blocking until the counter value equals 0.

There was multiple synchronization problems with the actor library :
* The creation of `async`, aka the proxy wasn't synchronized, which means we could create multiple instances of an actor if multiple threads called `async` on an object simultaneously
* Due to the asynchronous start of an actor (a new on a Nit Thread can return before the actual underlying C pthread started running), there was some cases where the mecanism used to wait for every actors to be idle before exiting a program was broken.

This PR adresses theses 2 bugs. The first one is just adding a mutex used for the creation of the `async` object.

The second one was adressed by moving the logic dealing with the idle state of an actor directly into his mailbox.

This PR also makes it possible to redefine an actor class. `lib/actors/agent_simulation` provides an example of this feature:
* `agent_simulation.nit` defines a simple api to which defines a Multi-agent simulation. The `ClockWorker` is in charge of the simulation and executes every steps, waiting for one to be finished before launching the other. the list of `Agent` it manages are all the agents of the simulation, which are actors too.
* `simple_simulation.nit` redefine the `Agent` class to add specific services for a specific simulation. Here, each agent knows every other one in the simluation and greets them, wait to be greeted back by everyone, then signals the clock that it finished the step.

This feature can be useful, but hasn't been fully tested yet. Furthermore, the Nit actor model still doesn't support subclassing an actor, which could also be really useful.

Well, that's pretty much it, enjoy reading :p

Pull-Request: #2425
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>

6 years agonitin: use GPL-3.0 instead of GPL-3
Jean Privat [Tue, 6 Jun 2017 13:28:10 +0000 (09:28 -0400)]
nitin: use GPL-3.0 instead of GPL-3

because https://opensource.org/licenses/GPL-3.0 works
whereas it is broken without the .0

Signed-off-by: Jean Privat <jean@pryen.org>

6 years agolib/core: introduce replace_first in text/string_search
Alexandre Terrasa [Tue, 6 Jun 2017 05:44:15 +0000 (01:44 -0400)]
lib/core: introduce replace_first in text/string_search

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

6 years agotinks, model_viewer & action_nitro: print model loading errors and fix one
Alexis Laferrière [Wed, 31 May 2017 13:08:01 +0000 (09:08 -0400)]
tinks, model_viewer & action_nitro: print model loading errors and fix one

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: collect errors when loading models and its textures
Alexis Laferrière [Wed, 31 May 2017 13:07:08 +0000 (09:07 -0400)]
gamnit: collect errors when loading models and its textures

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: don't load the same .mat material more than once
Alexis Laferrière [Wed, 31 May 2017 13:06:01 +0000 (09:06 -0400)]
gamnit: don't load the same .mat material more than once

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: replace the Lambert shader by a Blinn-Phong shader
Alexis Laferrière [Sat, 27 May 2017 20:45:32 +0000 (16:45 -0400)]
gamnit: replace the Lambert shader by a Blinn-Phong shader

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogeometry: rework `Float::angle_lerp` in the style of `Float::lerp`
Alexis Laferrière [Wed, 31 May 2017 02:00:01 +0000 (22:00 -0400)]
geometry: rework `Float::angle_lerp` in the style of `Float::lerp`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: 3 Euler rotation angles for actors
Alexis Laferrière [Wed, 24 May 2017 14:11:10 +0000 (07:11 -0700)]
gamnit: 3 Euler rotation angles for actors

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agosearch_tests.sh: Unquote results
Jean-Christophe Beaupré [Sat, 3 Jun 2017 21:33:38 +0000 (17:33 -0400)]
search_tests.sh: Unquote results

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agosearch_tests.sh: Update to the new format of `listfull.sh`
Jean-Christophe Beaupré [Sat, 3 Jun 2017 05:53:37 +0000 (01:53 -0400)]
search_tests.sh: Update to the new format of `listfull.sh`

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agolistfull.sh: Quote paths
Jean-Christophe Beaupré [Fri, 2 Jun 2017 15:30:24 +0000 (11:30 -0400)]
listfull.sh: Quote paths

Make the list unambiguous and easy to consume by POSIX shell scripts.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agotestfull.sh: Use `xargs`
Jean-Christophe Beaupré [Sat, 3 Jun 2017 17:55:35 +0000 (13:55 -0400)]
testfull.sh: Use `xargs`

That way, `listfull.sh` can quote the paths

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agomodelbuilder_base: Refactor the signature of `resolve_mtype*`
Jean-Christophe Beaupré [Fri, 2 Jun 2017 15:04:43 +0000 (11:04 -0400)]
modelbuilder_base: Refactor the signature of `resolve_mtype*`

Only `modelize_mclass` require support for partial context. Furthermore, in
a future PR, it may need to resolve types just before modeling the class
definition (in a place where the `MClass` is available and must be used).

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agomodelbuilder_base: Rename some local variables
Jean-Christophe Beaupré [Fri, 2 Jun 2017 02:43:40 +0000 (22:43 -0400)]
modelbuilder_base: Rename some local variables

Avoid a name conflict in future commits.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agotyping: Make `TypeVisitor::mmodule` implicit
Jean-Christophe Beaupré [Thu, 1 Jun 2017 21:37:14 +0000 (17:37 -0400)]
typing: Make `TypeVisitor::mmodule` implicit

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agotyping: Make `TypeVisitor::anchor` non-nullable
Jean-Christophe Beaupré [Fri, 2 Jun 2017 01:19:04 +0000 (21:19 -0400)]
typing: Make `TypeVisitor::anchor` non-nullable

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agolib/popcorn: import pop_json when needed
Alexandre Terrasa [Fri, 2 Jun 2017 14:32:55 +0000 (10:32 -0400)]
lib/popcorn: import pop_json when needed

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

6 years agolib/popcorn: move json related services to `pop_json`
Alexandre Terrasa [Thu, 25 May 2017 23:32:59 +0000 (19:32 -0400)]
lib/popcorn: move json related services to `pop_json`

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

6 years agolib/popcorn: add useful services for JSON REST handlers
Alexandre Terrasa [Thu, 25 May 2017 23:32:19 +0000 (19:32 -0400)]
lib/popcorn: add useful services for JSON REST handlers

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

6 years agotyping: Make `TypeVisitor::mclassdef` non-nullable
Jean-Christophe Beaupré [Fri, 2 Jun 2017 01:18:53 +0000 (21:18 -0400)]
typing: Make `TypeVisitor::mclassdef` non-nullable

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agotyping: Make `TypeVisitor::mpropdef` non-nullable
Jean-Christophe Beaupré [Thu, 1 Jun 2017 21:36:29 +0000 (17:36 -0400)]
typing: Make `TypeVisitor::mpropdef` non-nullable

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agotyping: Remove duplicate assignment to `TypeVisitor::mpropdef`
Jean-Christophe Beaupré [Thu, 1 Jun 2017 21:32:55 +0000 (17:32 -0400)]
typing: Remove duplicate assignment to `TypeVisitor::mpropdef`

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agomodelize_class: Fix spacing
Jean-Christophe Beaupré [Fri, 2 Jun 2017 02:15:36 +0000 (22:15 -0400)]
modelize_class: Fix spacing

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agogmp: Introduce NativeMPZ and NativeMPQ with simple test
PatrickBlanchette [Mon, 15 May 2017 13:56:46 +0000 (09:56 -0400)]
gmp: Introduce NativeMPZ and NativeMPQ with simple test

Signed-off-by: PatrickBlanchette <PatrickBlanchette@users.noreply.github.com>

6 years agogamnit: extract Cuboid as super class to cube and intro Boxed3d::to_mesh
Alexis Laferrière [Sat, 20 May 2017 17:50:13 +0000 (10:50 -0700)]
gamnit: extract Cuboid as super class to cube and intro Boxed3d::to_mesh

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: differentiate background from default material and explain perf stats
Alexis Laferrière [Thu, 18 May 2017 19:47:44 +0000 (12:47 -0700)]
gamnit: differentiate background from default material and explain perf stats

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: implement `lock_cursor` using SDL2 `relative_mouse_mode`
Alexis Laferrière [Wed, 17 May 2017 13:58:35 +0000 (06:58 -0700)]
gamnit: implement `lock_cursor` using SDL2 `relative_mouse_mode`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agoIntroducing agent simulation: an actor redefinition example
BlackMinou [Mon, 8 May 2017 17:59:28 +0000 (13:59 -0400)]
Introducing agent simulation: an actor redefinition example

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

6 years agoGenerate appropriate code for actors redefinitions
BlackMinou [Mon, 8 May 2017 17:52:15 +0000 (13:52 -0400)]
Generate appropriate code for actors redefinitions

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

6 years agouse `SynchronizedCounter` in chameneos-redux
BlackMinou [Mon, 8 May 2017 17:50:02 +0000 (13:50 -0400)]
use `SynchronizedCounter` in chameneos-redux

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

6 years agoFix synchronizations problem to better track active actors
BlackMinou [Mon, 8 May 2017 02:06:54 +0000 (22:06 -0400)]
Fix synchronizations problem to better track active actors

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

6 years agoMove `BlockingQueue` and `ReverseBlockingQueue` to `concurrent_collection`
BlackMinou [Mon, 8 May 2017 02:03:39 +0000 (22:03 -0400)]
Move `BlockingQueue` and `ReverseBlockingQueue` to `concurrent_collection`

Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

6 years agogamnit: add server discovery or create example
Alexis Laferrière [Tue, 30 May 2017 15:19:04 +0000 (11:19 -0400)]
gamnit: add server discovery or create example

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: add more options to `accept_clients` & `broadcast`
Alexis Laferrière [Sun, 28 May 2017 19:31:06 +0000 (15:31 -0400)]
gamnit: add more options to `accept_clients` & `broadcast`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: tweak network doc
Alexis Laferrière [Sun, 28 May 2017 19:49:45 +0000 (15:49 -0400)]
gamnit: tweak network doc

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: move up UDP discovery logic from Tinks! to the lib
Alexis Laferrière [Sun, 28 May 2017 02:03:21 +0000 (22:03 -0400)]
gamnit: move up UDP discovery logic from Tinks! to the lib

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agoparser_nodes: Fix spelling mistakes
Jean-Christophe Beaupré [Tue, 30 May 2017 00:25:52 +0000 (20:25 -0400)]
parser_nodes: Fix spelling mistakes

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agomodelize_class: Remove the `useless-bound` warning
Jean-Christophe Beaupré [Tue, 30 May 2017 03:31:37 +0000 (23:31 -0400)]
modelize_class: Remove the `useless-bound` warning

With class subsets, there is no bound that is useless.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agoMerge: geometry: implement 3D `dist` and improve API
Jean Privat [Mon, 29 May 2017 15:07:16 +0000 (11:07 -0400)]
Merge: geometry: implement 3D `dist` and improve API

The main change in this PR is the reimplementation of `Point::dist` and `dist2` to support 3D points, including comparing 2D and 3D points. The double dispatch logic is a bit complex but it works with any receiver.

This PR also tweaks existing services to improve the API and doc:
* Make all attributes of `Point` optional for gradual creation/space allocation. In practice, points are often created with a default value, as a kind of buffer, or with the Z axis at 0.
* Rework `BoxedArray` as a subclass of `Array` to inherit its services (incl. `remove`) while using less code.
* Move the custom `to_s` from the concrete boxes to the interfaces as it is very useful when debugging.

Pull-Request: #2462

6 years agoMerge: lib/popcorn: introduce `AppConfig::app_hostname`
Jean Privat [Mon, 29 May 2017 15:07:15 +0000 (11:07 -0400)]
Merge: lib/popcorn: introduce `AppConfig::app_hostname`

Introduce `app_hostname` in popcorn AppConfig.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

Pull-Request: #2464

6 years agoMerge: gamnit & sdl2: implement app::audio using SDL2 mixer
Jean Privat [Mon, 29 May 2017 15:07:14 +0000 (11:07 -0400)]
Merge: gamnit & sdl2: implement app::audio using SDL2 mixer

Intro a decent implementation of `app::audio` for desktop computers using SDL2 mixer. It supports WAV, MP3, OGG and more. The underlying SDL2 mixer bindings are minimal, they offer only the required features, more can be added as needed.

Clients of the gamnit framework will need to `apt-get install libsdl2-mixer-dev`.

Pull-Request: #2466

6 years agogeometry: implement `Point::dist` for 3D points
Alexis Laferrière [Sat, 20 May 2017 17:45:03 +0000 (10:45 -0700)]
geometry: implement `Point::dist` for 3D points

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogeometry: make `BoxedArray` a subclass of `Array`
Alexis Laferrière [Sat, 20 May 2017 17:44:03 +0000 (10:44 -0700)]
geometry: make `BoxedArray` a subclass of `Array`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogeometry: make the attributes of points optional
Alexis Laferrière [Thu, 18 May 2017 19:52:26 +0000 (12:52 -0700)]
geometry: make the attributes of points optional

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogeometry: move up custom `to_s` to the interfaces
Alexis Laferrière [Thu, 18 May 2017 19:51:23 +0000 (12:51 -0700)]
geometry: move up custom `to_s` to the interfaces

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: implement app::audio for desktop using SDL2 mixer
Alexis Laferrière [Thu, 25 May 2017 16:56:08 +0000 (12:56 -0400)]
gamnit: implement app::audio for desktop using SDL2 mixer

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agosdl2: intro minimal bindings to SDL2 mixer
Alexis Laferrière [Fri, 26 May 2017 00:02:42 +0000 (20:02 -0400)]
sdl2: intro minimal bindings to SDL2 mixer

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agoaudio: move some services between the abstraction and the Android layers
Alexis Laferrière [Thu, 25 May 2017 23:59:01 +0000 (19:59 -0400)]
audio: move some services between the abstraction and the Android layers

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agolib/popcorn: introduce `AppConfig::app_hostname`
Alexandre Terrasa [Thu, 25 May 2017 22:30:23 +0000 (18:30 -0400)]
lib/popcorn: introduce `AppConfig::app_hostname`

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

6 years agoMerge: Popcorn templates
Jean Privat [Thu, 25 May 2017 14:55:23 +0000 (10:55 -0400)]
Merge: Popcorn templates

# Template rendering for popcorn

## Basic templates

Use TemplateString to render really basic templates that just need macro
replacements.

Example:
~~~nit
class TemplateStringHandler
        super Handler
redef fun get(req, res) do
# Values to add in the template
var values = new HashMap[String, String]
values["USER"] = "Morriar"
values["MYSITE"] = "My super website"

# Render it with a shortcut
res.template_string("""
<h1>Hello %USER%!</h1>
<p>Welcome to %MYSITE%.</p>
""", values)
end
 end
 ~~~

 For larger templates, you can also use external files (makes your Nit code cleaner):
 ~~~nit
 class TemplateFileHandler
super Handler

redef fun get(req, res) do
# Values to add in the template
var values = new HashMap[String, String]
values["USER"] = "Morriar"
values["MYSITE"] = "My super website"

# Render it from an external file
res.template_file("example_template.tpl", values)
end
 end
 ~~~

 ## Using pug templates

 Pug is a templating format provided by the external command `pug`.
 For complex templates that need conditional or loop statements, pug can be a solution.

 See the pug syntax here: https://pugjs.org/api/getting-started.html

 ~~~nit
 class PugFileHandler
super Handler

redef fun get(req, res) do
# Values to add in the template
var json = new JsonObject
json["user"] = "Morriar"
json["mysite"] = "My super website"

# Render it from an external file
res.pug_file("example_template.pug", json)
end
 end
 ~~~

Pull-Request: #2449
Reviewed-by: Jean Privat <jean@pryen.org>

6 years agoMerge: coloring: Only generate strictly positive IDs
Jean Privat [Thu, 25 May 2017 14:55:22 +0000 (10:55 -0400)]
Merge: coloring: Only generate strictly positive IDs

This will allow to reserve negative IDs (including 0) for special purposes.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2457
Reviewed-by: Jean Privat <jean@pryen.org>

6 years agoMerge: model: Do not assume enums to be final
Jean Privat [Thu, 25 May 2017 14:55:21 +0000 (10:55 -0400)]
Merge: model: Do not assume enums to be final

An upcoming feature will destroy this assumption.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2458

6 years agoMerge: gamnit: intro support for Angel Code bitmap font
Jean Privat [Thu, 25 May 2017 14:55:20 +0000 (10:55 -0400)]
Merge: gamnit: intro support for Angel Code bitmap font

The BMFont format supports packed textures, varying advance per character and even kernings. It can be generated by a number of tools, including:
* BMFont, free software Windows app, http://www.angelcode.com/products/bmfont/
* Littera, a web app, http://kvazars.com/littera/

This PR also generalizes the `Font` and `TextSprites` concepts, previously limited to tile set bitmap fonts. And add a new shortcut service to the excellent DOM parser used to parse the XML description.

The result is much nicer than what was previously available, you can see it in a preview of my latest project:
![screenshot from 2017-05-22 12-38-55](https://cloud.githubusercontent.com/assets/208057/26353142/eeeb29a6-3f8c-11e7-847d-b5ccc8a93822.png)

The parsing method crash easily on malformatted font description file. However, since the description file should be generated, loaded at game start and not often modified, all expected crash errors should occur in dev only. Errors that can happen in production, like a truncated file or a misplaced file, should be detected by the basic sanity checks.

If an error occurs while loading a font, there is currently no automatic fallback and it will probably lead to an unusable game. It could be remedied by adding a default font, similar to the default material and mesh. It would be very useful, even at the beginning of any projects, but there is some technical limitations to implementing it as of now.

In the future, I plan on moving up more services from `TileSetFont` and add text alignment features. The `flat` module needs to be split in a group to include more services, including fonts.

Pull-Request: #2459
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

6 years agogamnit: intro BMFont parser and drawing services
Alexis Laferrière [Mon, 22 May 2017 18:12:42 +0000 (11:12 -0700)]
gamnit: intro BMFont parser and drawing services

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agogamnit: extract general Font from TileSetFont
Alexis Laferrière [Mon, 22 May 2017 17:51:16 +0000 (10:51 -0700)]
gamnit: extract general Font from TileSetFont

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agodom: intro `XMLTag::attributes_to_map` mapping `XMLStringAttr` to their value
Alexis Laferrière [Sun, 21 May 2017 15:54:56 +0000 (08:54 -0700)]
dom: intro `XMLTag::attributes_to_map` mapping `XMLStringAttr` to their value

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agotests: Update error messages
Jean-Christophe Beaupré [Tue, 23 May 2017 16:10:19 +0000 (12:10 -0400)]
tests: Update error messages

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agomodel: Do not assume enums to be final
Jean-Christophe Beaupré [Tue, 23 May 2017 04:12:49 +0000 (00:12 -0400)]
model: Do not assume enums to be final

An upcoming feature will destroy this assumption.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agotests: Do not rely on the implicit fixing of type bounds
Jean-Christophe Beaupré [Tue, 23 May 2017 16:09:49 +0000 (12:09 -0400)]
tests: Do not rely on the implicit fixing of type bounds

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agoMerge: model: Fix minor documentation mistakes
Jean Privat [Tue, 23 May 2017 15:24:00 +0000 (11:24 -0400)]
Merge: model: Fix minor documentation mistakes

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2451

6 years agoMerge: nitvm: Factorize the loading of superclasses
Jean Privat [Tue, 23 May 2017 15:23:59 +0000 (11:23 -0400)]
Merge: nitvm: Factorize the loading of superclasses

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2452

6 years agoMerge: parser_nodes: Fix documentation
Jean Privat [Tue, 23 May 2017 15:23:58 +0000 (11:23 -0400)]
Merge: parser_nodes: Fix documentation

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2453

6 years agoMerge: rosettacode: Fix spelling mistakes
Jean Privat [Tue, 23 May 2017 15:23:57 +0000 (11:23 -0400)]
Merge: rosettacode: Fix spelling mistakes

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2454

6 years agoMerge: rapid_type_analysis: Fix a spelling mistake
Jean Privat [Tue, 23 May 2017 15:23:56 +0000 (11:23 -0400)]
Merge: rapid_type_analysis: Fix a spelling mistake

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2455

6 years agodom: return a more precise `Array[XMLTag]` as the doc already said
Alexis Laferrière [Sun, 21 May 2017 15:54:21 +0000 (08:54 -0700)]
dom: return a more precise `Array[XMLTag]` as the doc already said

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

6 years agometrics_base: Do not rely on the implicit fixing of type bounds
Jean-Christophe Beaupré [Tue, 23 May 2017 04:13:38 +0000 (00:13 -0400)]
metrics_base: Do not rely on the implicit fixing of type bounds

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agoopts: Do not rely on the implicit fixing of type bounds
Jean-Christophe Beaupré [Tue, 9 May 2017 17:42:25 +0000 (13:42 -0400)]
opts: Do not rely on the implicit fixing of type bounds

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agocoloring: Only generate strictly positive IDs
Jean-Christophe Beaupré [Sun, 21 May 2017 23:20:58 +0000 (19:20 -0400)]
coloring: Only generate strictly positive IDs

This will allow to reserve negative IDs (including 0) for special purposes.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agocoloring: Fix documentation formatting
Jean-Christophe Beaupré [Sun, 21 May 2017 23:24:10 +0000 (19:24 -0400)]
coloring: Fix documentation formatting

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agorapid_type_analysis: Fix a spelling mistake
Jean-Christophe Beaupré [Thu, 9 Mar 2017 03:23:26 +0000 (22:23 -0500)]
rapid_type_analysis: Fix a spelling mistake

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agorosettacode: Fix spelling mistakes
Jean-Christophe Beaupré [Sat, 20 May 2017 23:06:39 +0000 (19:06 -0400)]
rosettacode: Fix spelling mistakes

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agoparser_nodes: Fix documentation
Jean-Christophe Beaupré [Fri, 19 May 2017 19:15:52 +0000 (15:15 -0400)]
parser_nodes: Fix documentation

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

6 years agomodel: Fix minor documentation mistakes
Jean-Christophe Beaupré [Thu, 18 May 2017 16:39:30 +0000 (12:39 -0400)]
model: Fix minor documentation mistakes

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>