The Play bundle is now Kryon's Google Play edition (app.edition=gplay). It compiles Kryon's PlayBilling class from the Kryon checkout, adds Play Billing 9.1.0 with one Kotlin version, uses AndroidX and needs Android 6. Entity's edition turns Monero funding off there, so the Profile's Top up opens Entity's Dew page with Play's prices instead of dew.waozi.xyz; Arcade no longer disables funding itself. The direct download keeps Monero.
121 lines
4.1 KiB
Ziran
121 lines
4.1 KiB
Ziran
// Only the outer native app owns Entity. Portable game collections contain
|
|
// games only, so embedding hosts keep their existing profile and account.
|
|
#import "entity/native_host"
|
|
#import "entity/model"
|
|
#import "std/file"
|
|
#import "std/c_string"
|
|
#import "std/vec"
|
|
#import "std/text_buffer"
|
|
#import "kryon/session"
|
|
#import "kryon/geometry"
|
|
#import "kryon/key_input"
|
|
#import "kryon/button_props"
|
|
#import "kryon/button_widget"
|
|
#import "platform"
|
|
#import "shovey/shovey_theme"
|
|
#import "kryon/widget_palette"
|
|
#import "apps/appearance"
|
|
#import "kryon/drawing_props"
|
|
#import "kryon/box_widget"
|
|
#import "kryon/box_props"
|
|
#import "kryon/text_widget"
|
|
#import "kryon/text_props"
|
|
#import "kryon/modal_props"
|
|
#import "kryon/modal_frame_widget"
|
|
#import "kryon/tree"
|
|
|
|
entity_bundle: string;
|
|
entity_ready: bool;
|
|
entity_visible: bool;
|
|
entity_shovey: bool;
|
|
entity_typed: [1024]u8;
|
|
|
|
// The profile's theme tokens in Shovey's slate, like the game around it.
|
|
EntityShoveyTokens :: () {
|
|
names: [6]string = .["canvas", "surface", "border", "text", "accent", "link"]
|
|
colors: [6]u32 = .[0x2a2e2dff, 0x3b403fff, 0x5d6261ff, 0xe8eceaff, 0x34b930ff, 0x34b930ff]
|
|
for index: 0..5 {
|
|
name: [16]u8
|
|
for byte, at: names[index] { name[at] = byte }
|
|
unused SetStyleTokenColorBytes(name[:names[index].count], colors[index])
|
|
}
|
|
}
|
|
|
|
EntityOpen :: (bytes: string, data: string, shovey: bool = false) -> bool {
|
|
entity_shovey = shovey
|
|
if shovey { EntityShoveyTokens() }
|
|
root := Join(data, "entity")
|
|
defer { EntityFree(root) }
|
|
entity_ready = EntityHostOpen(bytes, root, "arcade", true)
|
|
return entity_ready
|
|
}
|
|
|
|
EntityOpenFile :: (directory: string, data: string, shovey: bool = false) -> bool {
|
|
path := Join(directory, "entity.zx")
|
|
defer { EntityFree(path) }
|
|
file := OpenRead(path)
|
|
if !file.valid { return false }
|
|
defer { unused CloseFile(file) }
|
|
size := FileSize(file)
|
|
if size <= 0 || size > 16777216 { return false }
|
|
bytes: Vec(u8)
|
|
for index: 0..size - 1 {
|
|
if !VecPush(bytes, cast(u8)0) { VecFree(bytes); return false }
|
|
}
|
|
if ReadAt(file, VecSlice(bytes, 0, size), 0) != size { VecFree(bytes); return false }
|
|
entity_bundle = BuilderFinish(bytes)
|
|
return EntityOpen(entity_bundle, data, shovey)
|
|
}
|
|
|
|
EntityShow :: () -> bool {
|
|
if !entity_ready { return false }
|
|
if entity_visible && !EntityHostSave() { return false }
|
|
// Return through Entity's own routes before opening either entry point.
|
|
for depth: cast(s32)0..7 { if !EntityHostBack() { break } }
|
|
EntityHostReload()
|
|
entity_visible = true
|
|
return true
|
|
}
|
|
|
|
EntityBack :: () -> bool {
|
|
if !entity_visible { return false }
|
|
if EntityHostBack() { return true }
|
|
if EntityHostSave() { entity_visible = false }
|
|
return true
|
|
}
|
|
|
|
EntityFrame :: (session: Session, viewport: Rectangle, key: s32, modifiers: s32) -> bool {
|
|
unused WidgetPaletteUse(session, ifx entity_shovey then ShoveyPalette() else AppCoversPalette())
|
|
defer { unused WidgetPaletteRestore(session) }
|
|
Box(session, BoxProps.{.key = cast(u64)49010, .bounds = viewport,
|
|
.fill = StyleTokenColorOr("canvas", Color.{239, 246, 244, 255})})
|
|
width := viewport.width - 32.0
|
|
height := viewport.height - 32.0
|
|
if width > 560.0 { width = 560.0 }
|
|
if height > 720.0 { height = 720.0 }
|
|
modal := ModalFrame(session, ModalFrameProps.{.key = cast(u64)49000, .id = 49000,
|
|
.title = "Profile", .width = cast(s32)width, .height = cast(s32)height, .scale = 1.0,
|
|
.has_right_action = true, .right_label = "Back"})
|
|
if modal.dismissed || modal.right_clicked { unused EntityBack() }
|
|
if !modal.opened { return true }
|
|
input := TextFieldInputFor(key, modifiers, TypedTextTake(session, entity_typed[:]))
|
|
ok := EntityHostFrame(session, modal.layout.content, key, modifiers, input, true)
|
|
unused End(session)
|
|
if !ok { return false }
|
|
return true
|
|
}
|
|
|
|
EntityPump :: () {
|
|
EntityHostPump()
|
|
}
|
|
|
|
EntityClose :: () -> bool {
|
|
if !entity_ready { return true }
|
|
if !EntityHostClose() { return false }
|
|
entity_ready = false
|
|
entity_visible = false
|
|
EntityFree(entity_bundle)
|
|
entity_bundle = ""
|
|
return true
|
|
}
|