Skip to content

Commit 8956e26

Browse files
committed
add: farbenblind Modus für Schlüssel und Türen
1 parent 3d20f2d commit 8956e26

12 files changed

+79
-12
lines changed

Assets/tileset.png

22 Bytes
Loading

Assets/translation.json

+3
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,9 @@
12471247
,"TXT_DIR_ALREADY_EXISTS" : {
12481248
"de" : "Verzeichnis existiert bereits!"
12491249
}
1250+
,"TXT_MENU_KEYS" : {
1251+
"de" : "farbige Schlüssel"
1252+
}
12501253
,"OBJ_ACID" : {
12511254
"de" : "Säure"
12521255
}

Source/Config.hx

+11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class Config {
1010
public static var speed:Int = 2;
1111
static var _speeds:Array<Float> = [0.5, 0.75, 1, 1.25, 1.5];
1212

13+
public static var colorKeys:Bool = true;
14+
1315
public static var robotStress:Bool = false;
1416
public static var robotBehavior:Int = 1;
1517

@@ -38,6 +40,8 @@ class Config {
3840
robotStress = Reflect.field(data, "robotStress");
3941
case "robotBehavior":
4042
robotBehavior = Reflect.field(data, "robotBehavior");
43+
case "colorKeys":
44+
colorKeys = Reflect.field(data, "colorKeys");
4145
}
4246
}
4347
}
@@ -50,6 +54,7 @@ class Config {
5054
data.set("shader", shader);
5155
data.set("robotStress", robotStress);
5256
data.set("robotBehavior", robotBehavior);
57+
data.set("colorKeys", colorKeys);
5358

5459
Files.saveToFile("config.json", TJSON.encode(data, 'fancy'));
5560
}
@@ -82,6 +87,12 @@ class Config {
8287
save();
8388
}
8489

90+
public static function setColoredKeys(value:Bool) {
91+
colorKeys = value;
92+
93+
save();
94+
}
95+
8596
public static function getSpeed(v:Float):Float {
8697
return v * _speeds[speed];
8798
}

Source/screens/EditorScreen.hx

+2-2
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ class EditorScreen extends PlayScreen {
529529
var py:Int = cursorY + yy;
530530

531531
if (px >= 0 && px < Room.WIDTH && py >= 1 && py <= Room.HEIGHT) {
532-
Gfx.drawSprite(px * Tobor.TILE_WIDTH, py * Tobor.TILE_HEIGHT, game.world.factory.get(currentTile).spr, COLOR_TRANSPARENT);
532+
Gfx.drawSprite(px * Tobor.TILE_WIDTH, py * Tobor.TILE_HEIGHT, Config.colorKeys?game.world.factory.get(currentTile).spr:game.world.factory.get(currentTile).sprBlack, COLOR_TRANSPARENT);
533533
if (xx == 0 && yy == 0) Gfx.drawSprite(px * Tobor.TILE_WIDTH, py * Tobor.TILE_HEIGHT, SPR_CURSOR, COLOR_TRANSPARENT);
534534
}
535535
}
@@ -557,7 +557,7 @@ class EditorScreen extends PlayScreen {
557557
Tobor.fontBig.drawString(9 * 16 + 8, 0, "[", Color.BLACK);
558558
Tobor.fontBig.drawString(11 * 16 - 4, 0, "]", Color.BLACK);
559559

560-
Gfx.drawSprite(10 * Tobor.TILE_WIDTH, 0, game.world.factory.get(currentTile).spr);
560+
Gfx.drawSprite(10 * Tobor.TILE_WIDTH, 0, Config.colorKeys?game.world.factory.get(currentTile).spr:game.world.factory.get(currentTile).sprBlack);
561561
// Gfx.drawSprite(10 * Tobor.TILE_WIDTH, 0, SPR_SELECTOR);
562562

563563
for (x in 0 ... 3) {

Source/screens/PlayScreen.hx

+30
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,33 @@ class PlayScreen extends Screen {
377377
showDialog(menu);
378378
}
379379

380+
function showKeysMenu(atX:Int = 320, atY:Int = 166) {
381+
var menu = new DialogMenu(this, atX, atY, [
382+
[Text.get("TXT_OFF"), "", function () {
383+
Config.setColoredKeys(false);
384+
game.world.inventory.refresh(game.world.factory);
385+
hideDialog();
386+
}],
387+
[Text.get("TXT_ON"), "", function () {
388+
Config.setColoredKeys(true);
389+
game.world.inventory.refresh(game.world.factory);
390+
hideDialog();
391+
}],
392+
]);
393+
394+
menu.select(Config.colorKeys?1:0);
395+
396+
menu.onCancel = function (atX, atY) {
397+
showOptionMenu();
398+
};
399+
400+
menu.onOk = function () {
401+
402+
};
403+
404+
showDialog(menu);
405+
}
406+
380407
function showLightMenu(atX:Int = 320, atY:Int = 166) {
381408
var menu = new DialogMenu(this, atX, atY, [
382409
[Text.get("Dithering"), "", function () {
@@ -453,6 +480,9 @@ class PlayScreen extends Screen {
453480
[Text.get("TXT_MENU_LIGHT"), ">>", function () {
454481
showLightMenu(atX, atY);
455482
}],
483+
[Text.get("TXT_MENU_KEYS"), ">>", function () {
484+
showKeysMenu(atX, atY);
485+
}],
456486
["- Debug -", "", function () {
457487

458488
}],

Source/ui/DialogTiles.hx

+6-4
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,22 @@ class DialogTiles extends Dialog {
141141

142142
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, SPR_NONE);
143143

144+
var tile_spr = Config.colorKeys?t.spr:t.sprBlack;
145+
144146
if (editor.currentTile == i) {
145147
if (t.canBePlaced) {
146-
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, t.spr);
148+
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, tile_spr);
147149
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, SPR_SELECTOR);
148150
} else {
149151
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, SPR_NONE, Color.RED);
150-
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, t.spr, Color.RED);
152+
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, tile_spr, Color.RED);
151153
}
152154
} else {
153155
if (t.canBePlaced) {
154-
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, t.spr, Color.DARK_GREEN);
156+
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, tile_spr, Color.DARK_GREEN);
155157
} else {
156158
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, SPR_NONE, Color.RED);
157-
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, t.spr, Color.DARK_RED);
159+
Gfx.drawSprite((4 + tX) * Tobor.TILE_WIDTH, tY * Tobor.TILE_HEIGHT, tile_spr, Color.DARK_RED);
158160
}
159161
}
160162

Source/world/Inventory.hx

+12-1
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,24 @@ class Inventory {
7474
var count:Int = Reflect.field(dataItem, "count");
7575
var content:String = Reflect.field(dataItem, "content");
7676

77-
add(key, template.spr, count, content);
77+
add(key, Config.colorKeys?template.spr:template.sprBlack, count, content);
7878
} else {
7979
trace("Couldn't find inventory item: " + key);
8080
}
8181
}
8282
}
8383

84+
public function refresh(factory:ObjectFactory) {
85+
for (itm in list) {
86+
if (itm.group == "OBJ_KEY") {
87+
var tmp = factory.findFromID(itm.id);
88+
if (tmp != null) {
89+
itm.spr = Config.colorKeys?tmp.spr:tmp.sprBlack;
90+
}
91+
}
92+
}
93+
}
94+
8495
public function save():Map<String, Dynamic> {
8596
var data:Map<String, Dynamic> = new Map<String, Dynamic>();
8697

Source/world/InventoryItem.hx

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class InventoryItem {
1111

1212
public var group:String;
1313
public var id:String;
14+
1415
public var spr:Sprite;
1516

1617
public var content:String;

Source/world/ObjectFactory.hx

+9-2
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,18 @@ class ObjectFactory {
166166
// Türen
167167

168168
for (i in 0 ... 15) {
169-
register("OBJ_DOOR#" + Std.string(i), Door, Gfx.getSprite(i * 16, 36), {type: i})
169+
var door = register("OBJ_DOOR#" + Std.string(i), Door, Gfx.getSprite(i * 16, 36), {type: i})
170170
.disableBrush();
171+
172+
door.sprBlack = Gfx.getSprite(i * 16, 192);
171173
}
172174

173175
for (i in 0 ... 15) {
174-
register("OBJ_KEY#" + Std.string(i), Key, Gfx.getSprite(i * 16, 48), {type: i})
176+
var key = register("OBJ_KEY#" + Std.string(i), Key, Gfx.getSprite(i * 16, 48), {type: i})
175177
.setPoints(500)
176178
.disableBrush();
179+
180+
key.sprBlack = Gfx.getSprite(i * 16, 204);
177181
}
178182

179183
register("OBJ_EXPLOSION", Explosion, Gfx.getSprite(64, 0))
@@ -656,7 +660,9 @@ class ObjectTemplate {
656660
public var name:String;
657661
public var classPath:Class<Entity>;
658662
public var data:Dynamic;
663+
659664
public var spr:Sprite;
665+
public var sprBlack:Sprite;
660666

661667
public var points:Int;
662668

@@ -670,6 +676,7 @@ class ObjectTemplate {
670676
this.classPath = c;
671677
this.data = d;
672678
this.spr = spr;
679+
this.sprBlack = spr;
673680
this.layer = layer;
674681

675682
if (d != null) {

Source/world/entities/EntityItem.hx

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class EntityItem extends EntityCollectable {
5959
}, template.points);
6060
}
6161

62-
getInventory().add(template.name, template.spr, num, content);
62+
getInventory().add(template.name, Config.colorKeys?template.spr:template.sprBlack, num, content);
6363
}
6464

6565
return firstTime;

Source/world/entities/std/Door.hx

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import world.entities.EntityStatic;
1010
*/
1111
class Door extends EntityStatic {
1212
public static var SPR_DOOR:Array<Sprite> = Gfx.getSprites(null, 0, 36, 0, 16);
13+
public static var SPR_DOOR_BLACK:Array<Sprite> = Gfx.getSprites(null, 0, 192, 0, 16);
1314

1415
public function new() {
1516
super();
1617
}
1718

1819
override public function render() {
19-
Gfx.drawSprite(x * Tobor.TILE_WIDTH, y * Tobor.TILE_HEIGHT, SPR_DOOR[type]);
20+
Gfx.drawSprite(x * Tobor.TILE_WIDTH, y * Tobor.TILE_HEIGHT, Config.colorKeys?SPR_DOOR[type]:SPR_DOOR_BLACK[type]);
2021
}
2122

2223
override public function canEnter(e:Entity, direction:Vector2, ?speed:Float = 0):Bool {

Source/world/entities/std/Key.hx

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import world.entities.EntityItem;
88
*/
99
class Key extends EntityItem {
1010
public static var SPR_KEY:Array<Sprite> = Gfx.getSprites(null, 0, 48, 0, 16);
11+
public static var SPR_KEY_BLACK:Array<Sprite> = Gfx.getSprites(null, 0, 204, 0, 16);
1112

1213
public function new() {
1314
super();
1415
}
1516

1617
override public function render() {
17-
Gfx.drawSprite(x * Tobor.TILE_WIDTH, y * Tobor.TILE_HEIGHT, SPR_KEY[type]);
18+
Gfx.drawSprite(x * Tobor.TILE_WIDTH, y * Tobor.TILE_HEIGHT, Config.colorKeys?SPR_KEY[type]:SPR_KEY_BLACK[type]);
1819
}
1920

2021
override public function onPickup() {

0 commit comments

Comments
 (0)