some
This commit is contained in:
1 parent
738a5bffd0
commit
47f9eb904a
30 files changed
+339
-35
No files matched your search
@@ -0,0 +1,115 @@
|
||||
version: 4
|
||||
|
||||
output:
|
||||
game/ver-mac/src/dialect.swift:
|
||||
type: swift
|
||||
|
||||
ChkgfxComponent:
|
||||
type: component
|
||||
shoulds:
|
||||
didLaunch:
|
||||
1. Only once during the first setup:
|
||||
if:
|
||||
c.recentField == F.didSetup &&
|
||||
c.didLaunch == false
|
||||
then:
|
||||
c.didLaunch = true
|
||||
|
||||
ChkgfxContext:
|
||||
type: context
|
||||
fields:
|
||||
didClickLoadModel: Bool
|
||||
didLaunch: Bool
|
||||
didSetup: Bool
|
||||
|
||||
RenderContext:
|
||||
type: context
|
||||
fields:
|
||||
backingPixelSize: [Int32]
|
||||
didClickIncrement: Bool
|
||||
didLaunch: Bool
|
||||
didPrepareGL: Bool
|
||||
didSetup: Bool
|
||||
pixelSize: [Int32]
|
||||
reshapePixelSize: [Int32]
|
||||
willDeinit: Bool
|
||||
|
||||
RenderComponent:
|
||||
type: component
|
||||
oneliners:
|
||||
- didClickIncrement: renderLoadCubeModel(RenderVM.shared!)
|
||||
- didPrepareGL: renderInit(RenderVM.shared!)
|
||||
- didPrepareGL: RenderVM.shared!.didPrepareGL = true
|
||||
- didPrepareGL: renderStartTimer(RenderVM.shared!)
|
||||
- pixelSize: RenderVM.shared!.pixelSize = c.pixelSize
|
||||
- willDeinit: renderDeinit(RenderVM.shared!)
|
||||
shoulds:
|
||||
didLaunch:
|
||||
1. Only once during the first setup:
|
||||
if:
|
||||
c.recentField == F.didSetup &&
|
||||
c.didLaunch == false
|
||||
then:
|
||||
c.didLaunch = true
|
||||
pixelSize:
|
||||
1. Upon launch:
|
||||
if:
|
||||
c.recentField == F.didLaunch
|
||||
then:
|
||||
c.pixelSize = [1, 1]
|
||||
2. Upon resize:
|
||||
if:
|
||||
c.recentField == F.reshapePixelSize
|
||||
then:
|
||||
c.pixelSize = c.reshapePixelSize
|
||||
3. Upon DPI change:
|
||||
if:
|
||||
c.recentField == F.backingPixelSize
|
||||
then:
|
||||
c.pixelSize = c.backingPixelSize
|
||||
|
||||
RootComponent:
|
||||
type: component
|
||||
oneliners:
|
||||
- countText: RootVM.shared!.countText = c.countText
|
||||
- didClickIncrement: renderSet(F.didClickIncrement, true)
|
||||
shoulds:
|
||||
count:
|
||||
1. Upon hitting 10 the first time:
|
||||
if:
|
||||
c.recentField == F.didClickIncrement &&
|
||||
c.count == 7
|
||||
then:
|
||||
c.count += 10
|
||||
2. Upon each button click:
|
||||
if:
|
||||
c.recentField == F.didClickIncrement
|
||||
then:
|
||||
c.count += 1
|
||||
countText:
|
||||
1. Upon each count change:
|
||||
if:
|
||||
c.recentField == F.count
|
||||
then:
|
||||
c.countText = "Count: '\(c.count)'"
|
||||
2. Upon launch:
|
||||
if:
|
||||
c.recentField == F.didLaunch
|
||||
then:
|
||||
c.countText = "Press the button to count"
|
||||
didLaunch:
|
||||
1. Only once during the first setup:
|
||||
if:
|
||||
c.recentField == F.didSetup &&
|
||||
c.didLaunch == false
|
||||
then:
|
||||
c.didLaunch = true
|
||||
|
||||
RootContext:
|
||||
type: context
|
||||
fields:
|
||||
count: Int
|
||||
countText: String
|
||||
didClickIncrement: Bool
|
||||
didLaunch: Bool
|
||||
didSetup: Bool
|
||||
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>OGS Mahjong</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.opengamestudio.Mahjong</string>
|
||||
<string>org.opengamestudio.mahjong</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>ogs-mahjong</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
|
||||
@@ -7,7 +7,11 @@ struct GameApp: App {
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
RootView(appDelegate.rootVM)
|
||||
ZStack {
|
||||
RenderView()
|
||||
.ignoresSafeArea()
|
||||
RootView(appDelegate.rootVM)
|
||||
}
|
||||
}
|
||||
.defaultSize(width: 640, height: 480)
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ public struct F {
|
||||
public static let count = "count"
|
||||
public static let countText = "countText"
|
||||
public static let didClickIncrement = "didClickIncrement"
|
||||
public static let didClickLoadModel = "didClickLoadModel"
|
||||
public static let didLaunch = "didLaunch"
|
||||
public static let didPrepareGL = "didPrepareGL"
|
||||
public static let didSetup = "didSetup"
|
||||
@@ -131,6 +132,44 @@ public struct F {
|
||||
public static let willDeinit = "willDeinit"
|
||||
|
||||
}
|
||||
public struct ChkgfxContext: DialectContext {
|
||||
public var didClickLoadModel = Bool()
|
||||
public var didLaunch = Bool()
|
||||
public var didSetup = Bool()
|
||||
|
||||
public var recentField = ""
|
||||
|
||||
public func field<T>(_ name: String) -> T {
|
||||
if (name == "didClickLoadModel") {
|
||||
return didClickLoadModel as! T
|
||||
}
|
||||
else if (name == "didLaunch") {
|
||||
return didLaunch as! T
|
||||
}
|
||||
else if (name == "didSetup") {
|
||||
return didSetup as! T
|
||||
}
|
||||
|
||||
return "unknown-field-name" as! T
|
||||
}
|
||||
|
||||
public mutating func setField(
|
||||
_ name: String,
|
||||
_ value: Any
|
||||
) {
|
||||
if (name == "didClickLoadModel") {
|
||||
didClickLoadModel = value as! Bool
|
||||
}
|
||||
else if (name == "didLaunch") {
|
||||
didLaunch = value as! Bool
|
||||
}
|
||||
else if (name == "didSetup") {
|
||||
didSetup = value as! Bool
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public struct RenderContext: DialectContext {
|
||||
public var backingPixelSize = [Int32]()
|
||||
public var didClickIncrement = Bool()
|
||||
@@ -256,6 +295,13 @@ public struct RootContext: DialectContext {
|
||||
}
|
||||
}
|
||||
|
||||
public func chkgfxSet(
|
||||
_ key: String,
|
||||
_ value: Any
|
||||
) {
|
||||
ChkgfxComponent.singleton!.ctrl.set(key, value)
|
||||
}
|
||||
|
||||
public func renderSet(
|
||||
_ key: String,
|
||||
_ value: Any
|
||||
@@ -270,6 +316,24 @@ public func rootSet(
|
||||
RootComponent.singleton!.ctrl.set(key, value)
|
||||
}
|
||||
|
||||
func chkgfxShouldResetDidLaunch(_ c: ChkgfxContext) -> ChkgfxContext {
|
||||
var c = c
|
||||
|
||||
/* 1. Only once during the first setup */
|
||||
if
|
||||
c.recentField == F.didSetup &&
|
||||
c.didLaunch == false
|
||||
{
|
||||
c.didLaunch = true
|
||||
c.recentField = F.didLaunch
|
||||
return c
|
||||
}
|
||||
|
||||
|
||||
c.recentField = DIALECT_CONTEXT_RECENT_FIELD_NONE
|
||||
return c
|
||||
}
|
||||
|
||||
func renderShouldResetDidLaunch(_ c: RenderContext) -> RenderContext {
|
||||
var c = c
|
||||
|
||||
@@ -394,6 +458,15 @@ func rootShouldResetDidLaunch(_ c: RootContext) -> RootContext {
|
||||
return c
|
||||
}
|
||||
|
||||
func chkgfxRegisterShoulds(_ ctrl: DialectController) {
|
||||
[
|
||||
chkgfxShouldResetDidLaunch,
|
||||
|
||||
].forEach { f in
|
||||
ctrl.registerFunction { c in f(c as! ChkgfxContext) }
|
||||
}
|
||||
}
|
||||
|
||||
func renderRegisterShoulds(_ ctrl: DialectController) {
|
||||
[
|
||||
renderShouldResetDidLaunch,
|
||||
|
||||
Reference in new issue
Block a user