-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ece5a4
commit e3aac0e
Showing
19 changed files
with
1,172 additions
and
1,079 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,94 @@ | ||
package demo | ||
// package demo | ||
|
||
import indigo.* | ||
import roguelikestarterkit.* | ||
// import indigo.* | ||
// import roguelikestarterkit.* | ||
|
||
object ComponentsWindow: | ||
// object ComponentsWindow: | ||
|
||
private val graphic = Graphic(0, 0, TerminalMaterial(AssetName(""), RGBA.White, RGBA.Black)) | ||
// private val graphic = Graphic(0, 0, TerminalMaterial(AssetName(""), RGBA.White, RGBA.Black)) | ||
|
||
val windowId: WindowId = WindowId("ComponentsWindow") | ||
// val windowId: WindowId = WindowId("ComponentsWindow") | ||
|
||
def window( | ||
charSheet: CharSheet | ||
): WindowModel[ComponentGroup[Int], Int] = | ||
WindowModel( | ||
windowId, | ||
charSheet, | ||
ComponentGroup(Bounds(0, 0, 23, 23)) | ||
.withLayout(ComponentLayout.Vertical(Padding(0, 0, 1))) | ||
.inheritBounds | ||
.add( | ||
Button( | ||
"Hello!", | ||
Button.Theme( | ||
charSheet, | ||
RGBA.Silver -> RGBA.Black, | ||
RGBA.White -> RGBA.Black, | ||
RGBA.Black -> RGBA.White, | ||
hasBorder = true | ||
) | ||
) | ||
) | ||
.add( | ||
Button( | ||
"World!", | ||
Button.Theme( | ||
charSheet, | ||
RGBA.Silver -> RGBA.Black, | ||
RGBA.Green -> RGBA.Black, | ||
RGBA.Black -> RGBA.Yellow, | ||
hasBorder = false | ||
) | ||
), | ||
Button("Default!", Button.Theme(charSheet)) | ||
) | ||
.add { | ||
Button( | ||
(i: Int) => "Count" + (if i > 0 then s": $i" else ""), | ||
Button.Theme(charSheet).addBorder | ||
) | ||
} | ||
.add( | ||
Button[Int](Bounds(0, 0, 5, 2)) { case (coords, bounds, _) => | ||
Outcome( | ||
ComponentFragment( | ||
Shape.Box( | ||
bounds.toScreenSpace(charSheet.size).moveTo(coords.toScreenSpace(charSheet.size)), | ||
Fill.LinearGradient(Point.zero, RGBA.Cyan, Point(50, 0), RGBA.Magenta) | ||
) | ||
) | ||
) | ||
} | ||
) | ||
.add( | ||
Label("Custom rendered label") { case (offset, label, dimensions) => | ||
val size = dimensions.unsafeToSize | ||
// def window( | ||
// charSheet: CharSheet | ||
// ): WindowModel[ComponentGroup[Int], Int] = | ||
// WindowModel( | ||
// windowId, | ||
// charSheet, | ||
// // ComponentGroup(Bounds(0, 0, 23, 23)) | ||
// // .withLayout(ComponentLayout.Vertical(Padding(0, 0, 1))) | ||
// // .inheritBounds | ||
// // .add( | ||
// // Button( | ||
// // "Hello!", | ||
// // Button.Theme( | ||
// // charSheet, | ||
// // RGBA.Silver -> RGBA.Black, | ||
// // RGBA.White -> RGBA.Black, | ||
// // RGBA.Black -> RGBA.White, | ||
// // hasBorder = true | ||
// // ) | ||
// // ) | ||
// // ) | ||
// // .add( | ||
// // Button( | ||
// // "World!", | ||
// // Button.Theme( | ||
// // charSheet, | ||
// // RGBA.Silver -> RGBA.Black, | ||
// // RGBA.Green -> RGBA.Black, | ||
// // RGBA.Black -> RGBA.Yellow, | ||
// // hasBorder = false | ||
// // ) | ||
// // ), | ||
// // Button("Default!", Button.Theme(charSheet)) | ||
// // ) | ||
// // .add { | ||
// // Button( | ||
// // (i: Int) => "Count" + (if i > 0 then s": $i" else ""), | ||
// // Button.Theme(charSheet).addBorder | ||
// // ) | ||
// // } | ||
// // .add( | ||
// // Button[Int](Bounds(0, 0, 5, 2)) { case (coords, bounds, _) => | ||
// // Outcome( | ||
// // ComponentFragment( | ||
// // Shape.Box( | ||
// // bounds.toScreenSpace(charSheet.size).moveTo(coords.toScreenSpace(charSheet.size)), | ||
// // Fill.LinearGradient(Point.zero, RGBA.Cyan, Point(50, 0), RGBA.Magenta) | ||
// // ) | ||
// // ) | ||
// // ) | ||
// // } | ||
// // ) | ||
// // .add( | ||
// // Label[Int]("Custom rendered label", (_, t) => Bounds(0, 0, t.length, 1)) { | ||
// // case (offset, label, dimensions) => | ||
// // val size = dimensions.unsafeToSize | ||
|
||
val terminal = | ||
RogueTerminalEmulator(size) | ||
.putLine(Point.zero, label, RGBA.Red, RGBA.Zero) | ||
.toCloneTiles( | ||
CloneId("label"), | ||
offset.toScreenSpace(charSheet.size), | ||
charSheet.charCrops | ||
) { case (fg, bg) => | ||
graphic.withMaterial(TerminalMaterial(charSheet.assetName, fg, bg)) | ||
} | ||
// // val terminal = | ||
// // RogueTerminalEmulator(size) | ||
// // .putLine(Point.zero, label, RGBA.Red, RGBA.Zero) | ||
// // .toCloneTiles( | ||
// // CloneId("label"), | ||
// // offset.toScreenSpace(charSheet.size), | ||
// // charSheet.charCrops | ||
// // ) { case (fg, bg) => | ||
// // graphic.withMaterial(TerminalMaterial(charSheet.assetName, fg, bg)) | ||
// // } | ||
|
||
Outcome(ComponentFragment(terminal)) | ||
} | ||
) | ||
.add( | ||
Label("Terminal rendered label", Label.Theme(charSheet, RGBA.Magenta, RGBA.Cyan)), | ||
Label("Default theme", Label.Theme(charSheet)), | ||
Label((count: Int) => "Mouse over windows: " + count, Label.Theme(charSheet)) | ||
) | ||
) | ||
.withTitle("Components example") | ||
.moveTo(0, 0) | ||
.resizeTo(25, 25) | ||
.isDraggable | ||
.isResizable | ||
.isCloseable | ||
// // Outcome(ComponentFragment(terminal)) | ||
// // } | ||
// // ) | ||
// // .add( | ||
// // Label("Terminal rendered label", Label.Theme(charSheet, RGBA.Magenta, RGBA.Cyan)), | ||
// // Label("Default theme", Label.Theme(charSheet)), | ||
// // Label((count: Int) => "Mouse over windows: " + count, Label.Theme(charSheet)) | ||
// // ) | ||
// ) | ||
// .withTitle("Components example") | ||
// .moveTo(0, 0) | ||
// .resizeTo(25, 25) | ||
// .isDraggable | ||
// .isResizable | ||
// .isCloseable |
Oops, something went wrong.