Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Source/com/watabou/towngenerator/TownScene.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.watabou.utils.Random;
import com.watabou.towngenerator.medieval.Generator;
import com.watabou.towngenerator.medieval.Model;
import com.watabou.towngenerator.drawing.CityMap;
import com.watabou.towngenerator.drawing.Palette;

import com.watabou.towngenerator.ui.Button;
import com.watabou.towngenerator.ui.Tooltip;

Expand Down Expand Up @@ -48,8 +50,12 @@ class TownScene extends Scene {
var largeCity = new Button("Large City");
largeCity.click.add(function() { set_size(24, 40); });

var style = new Button("Style");
style.click.add(function() { set_palette(); });


var pos = 0.0;
for (btn in [smallTown, largeTown, smallCity, largeCity]) {
for (btn in [smallTown, largeTown, smallCity, largeCity, style]) {
btn.y = pos;
pos += btn.height + 1;
buttons.addChild( btn );
Expand All @@ -71,6 +77,15 @@ class TownScene extends Scene {
Game.switchScene( TownScene );
}

private function set_palette(): Void {

CityMap.palette = Palette.another();

map.draw();

}


override public function layout():Void {
map.x = rWidth / 2;
map.y = rHeight / 2;
Expand Down
9 changes: 9 additions & 0 deletions Source/com/watabou/towngenerator/drawing/CityMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ class CityMap extends Sprite {
this.model = model;
brush = new Brush( palette );

draw();

}

public function draw():Void {

if (stage != null)
stage.color = palette.paper;

for (road in model.roads) {
var roadView = new Shape();
drawRoad( roadView.graphics, road );
Expand Down
18 changes: 18 additions & 0 deletions Source/com/watabou/towngenerator/drawing/Palette.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,22 @@ class Palette {
public static var ANCIENT = new Palette( 0xccc5a3, 0xa69974, 0x806f4d, 0x342414 );
public static var COLOUR = new Palette( 0xfff2c8, 0xd6a36e, 0x869a81, 0x4c5950 );
public static var SIMPLE = new Palette( 0xffffff, 0x000000, 0x000000, 0x000000 );
public static var MOJEEB = new Palette( 0xF7EACA, 0x30D99C, 0xE7B632, 0xd93544 );

public static var PALETTES:Array<Palette> = [DEFAULT, BLUEPRINT, BW, INK, NIGHT, ANCIENT, COLOUR, SIMPLE, MOJEEB];

private static var iterator = PALETTES.iterator();

public static function another():Palette {
/*
if (iterator == null) {
iterator = PALETTES.iterator();
}
*/
if (!iterator.hasNext()) { // rewind??
iterator = PALETTES.iterator();
}

return iterator.next();
}
}