Added ability to switch ascii themes by pressing tab
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -66,6 +66,12 @@ void main() async {
|
|||||||
if (bytes.contains(113) || bytes.contains(27)) {
|
if (bytes.contains(113) || bytes.contains(27)) {
|
||||||
exitCleanly(0);
|
exitCleanly(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bytes.contains(9)) {
|
||||||
|
rasterizer.activeTheme = AsciiThemes.nextOf(rasterizer.activeTheme);
|
||||||
|
print("Switched to ${rasterizer.activeTheme.name} theme!");
|
||||||
|
}
|
||||||
|
|
||||||
input.handleKey(bytes);
|
input.handleKey(bytes);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import 'package:wolf_3d_dart/wolf_3d_data_types.dart';
|
|||||||
import 'package:wolf_3d_dart/wolf_3d_engine.dart';
|
import 'package:wolf_3d_dart/wolf_3d_engine.dart';
|
||||||
|
|
||||||
class AsciiTheme {
|
class AsciiTheme {
|
||||||
|
final String name;
|
||||||
|
|
||||||
/// The character ramp, ordered from most dense (index 0) to least dense (last index).
|
/// The character ramp, ordered from most dense (index 0) to least dense (last index).
|
||||||
final String ramp;
|
final String ramp;
|
||||||
|
|
||||||
const AsciiTheme(this.ramp);
|
const AsciiTheme(this.name, this.ramp);
|
||||||
|
|
||||||
/// Always returns the densest character (e.g., for walls, UI, floors)
|
/// Always returns the densest character (e.g., for walls, UI, floors)
|
||||||
String get solid => ramp[0];
|
String get solid => ramp[0];
|
||||||
@@ -27,9 +29,18 @@ class AsciiTheme {
|
|||||||
|
|
||||||
/// A collection of pre-defined character sets
|
/// A collection of pre-defined character sets
|
||||||
abstract class AsciiThemes {
|
abstract class AsciiThemes {
|
||||||
static const AsciiTheme blocks = AsciiTheme("█▓▒░ ");
|
static const AsciiTheme blocks = AsciiTheme('Blocks', "█▓▒░ ");
|
||||||
static const AsciiTheme classic = AsciiTheme("@%#*+=-:. ");
|
static const AsciiTheme classic = AsciiTheme('Classic', "@%#*+=-:. ");
|
||||||
static const AsciiTheme dense = AsciiTheme("█▇▆▅▄▃▂ ");
|
|
||||||
|
static const List<AsciiTheme> values = [blocks, classic];
|
||||||
|
|
||||||
|
static AsciiTheme nextOf(AsciiTheme current) {
|
||||||
|
final int currentIndex = values.indexOf(current);
|
||||||
|
final int nextIndex = currentIndex == -1
|
||||||
|
? 0
|
||||||
|
: (currentIndex + 1) % values.length;
|
||||||
|
return values[nextIndex];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ColoredChar {
|
class ColoredChar {
|
||||||
|
|||||||
Reference in New Issue
Block a user