diff --git a/SMILEBASIC/dialog.d b/SMILEBASIC/dialog.d new file mode 100644 index 0000000..0fab6b0 --- /dev/null +++ b/SMILEBASIC/dialog.d @@ -0,0 +1,66 @@ +module otya.smilebasic.dialog; +import otya.smilebasic.petitcomputer; +import derelict.sdl2.sdl; +import derelict.sdl2.image; +import derelict.opengl3.gl; +import derelict.opengl3.gl3; + +class DialogBase +{ + abstract void render(); +} + +enum SelectionType +{ + ok, + noYes, + backNext, + cancelConfirm, + cancelExecute, + next, +} + +enum ButtonResult +{ + a = 128, + b = 129, + x = 130, + y = 131, + up = 132, + down = 133, + left = 134, + right = 135, + l = 136, + r = 137, + touch = 140, +} + + +class Dialog : DialogBase +{ + private PetitComputer petitcom; + this(PetitComputer petitcom) + { + this.petitcom = petitcom; + } + private int result; + + override void render() + { + + } + + int show(wstring text) + { + petitcom.dialog = this; + auto area = petitcom.showTouchScreen(); + while (true) + { + auto to = petitcom.touchPosition(); + + } + petitcom.hideTouchScreen(); + return result; + } +} + diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index 3cd2e45..8e0c3a0 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -19,6 +19,7 @@ import otya.smilebasic.parser; import otya.smilebasic.project; import otya.smilebasic.console; import otya.smilebasic.graphic; +import otya.smilebasic.dialog; const static rot_test_deg = 45f; const static rot_test_x = 0f; const static rot_test_y = 1f; @@ -540,7 +541,12 @@ class PetitComputer this.sprite.spclip; } } + updateWindowSize(); + } + //do not call in synchronized(renderSync) + void updateWindowSize() + { SDL_SetWindowSize(window, cast(int)(currentDisplay.windowSize.width * scaleX), cast(int)(currentDisplay.windowSize.height * scaleY)); } @@ -813,6 +819,10 @@ class PetitComputer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); version(test) glLoadIdentity(); version(test) glRotatef(rot_test_deg, rot_test_x, rot_test_y, rot_test_z); + if (dialog) + { + dialog.render(); + } console.render(); graphic.render(); @@ -1607,6 +1617,30 @@ class PetitComputer wstring versionString = "3.5.0"; int version_ = 0x3050000; wstring[5] functionKey; + + DialogBase dialog; + SDL_Rect showTouchScreen() + { + if (currentDisplay.rect.length != 1) + { + return currentDisplay.rect[1]; + } + auto rect = currentDisplay.rect[0]; + rect.y += rect.h; + currentDisplay.windowSize.height += rect.h; + updateWindowSize(); + return rect; + } + void hideTouchScreen() + { + if (currentDisplay.rect.length != 1) + { + return; + } + auto rect = currentDisplay.rect[0]; + currentDisplay.windowSize.height -= rect.h; + updateWindowSize(); + } //プチコン内部表現はRGB5_A1 static uint toGLColor(GLenum format, ubyte r, ubyte g, ubyte b, ubyte a) { diff --git a/dub.json b/dub.json index 8730afb..cbc8708 100644 --- a/dub.json +++ b/dub.json @@ -4,7 +4,7 @@ "derelict-sdl2": "~>1.9.7", "derelict-gl3": "*" }, - "sourceFiles": ["SMILEBASIC/bg.d","SMILEBASIC/builtinfunctions.d","SMILEBASIC/compiler.d","SMILEBASIC/error.d","SMILEBASIC/main.d","SMILEBASIC/node.d","SMILEBASIC/parser.d","SMILEBASIC/petitcomputer.d","SMILEBASIC/sprite.d","SMILEBASIC/systemvariable.d","SMILEBASIC/token.d","SMILEBASIC/type.d","SMILEBASIC/VM.d","SMILEBASIC/project.d","SMILEBASIC/console.d","SMILEBASIC/graphic.d"], + "sourceFiles": ["SMILEBASIC/bg.d","SMILEBASIC/builtinfunctions.d","SMILEBASIC/compiler.d","SMILEBASIC/error.d","SMILEBASIC/main.d","SMILEBASIC/node.d","SMILEBASIC/parser.d","SMILEBASIC/petitcomputer.d","SMILEBASIC/sprite.d","SMILEBASIC/systemvariable.d","SMILEBASIC/token.d","SMILEBASIC/type.d","SMILEBASIC/VM.d","SMILEBASIC/project.d","SMILEBASIC/console.d","SMILEBASIC/graphic.d","SMILEBASIC/dialog.d"], "targetType": "executable", "buildRequirements": ["allowWarnings"], "targetPath": "out",