From 232def5197369657292fa96aa9acd32a683378d8 Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Tue, 25 Jan 2011 00:01:36 +0100 Subject: [PATCH] Add the PCRE license and start implementing the menu DSL. --- pongr/data/menu.data | 20 +++++------ pongr/doc/LICENSE.pcre.txt | 69 ++++++++++++++++++++++++++++++++++++++ pongr/src/Draw.pbi | 26 ++++++++++++-- pongr/src/Main.pb | 23 +++++++++++-- 4 files changed, 122 insertions(+), 16 deletions(-) create mode 100644 pongr/doc/LICENSE.pcre.txt diff --git a/pongr/data/menu.data b/pongr/data/menu.data index 1f236f1..a1af053 100644 --- a/pongr/data/menu.data +++ b/pongr/data/menu.data @@ -1,13 +1,13 @@ -MAIN_MENU "Pongr" - BUTTON: "Run game" -> RUNNING_GAME - BUTTON: "Options" -> OPTION_MENU - BUTTON: "QUIT" -> RLY_QUIT +MAIN_MENU {Pongr} + BUTTON: {Run game} -> RUNNING_GAME + BUTTON: {Options} -> OPTION_MENU + BUTTON: {QUIT} -> RLY_QUIT -OPTION_MENU "Options" - OPTION: "Fullscreen", "Window Mode" - BUTTON: "Back" -> MAIN_MENU +OPTION_MENU {Options} + OPTION: {Fullscreen}, {Window Mode} + BUTTON: {Back} -> MAIN_MENU -RLY_QUIT "You want to go?" - BUTTON: "Yes" -> EXIT - BUTTON: "No" -> MAIN_MENU +RLY_QUIT {You want to go?} + BUTTON: {Yes} -> EXIT + BUTTON: {No} -> MAIN_MENU diff --git a/pongr/doc/LICENSE.pcre.txt b/pongr/doc/LICENSE.pcre.txt new file mode 100644 index 0000000..9e1d198 --- /dev/null +++ b/pongr/doc/LICENSE.pcre.txt @@ -0,0 +1,69 @@ +PCRE LICENCE +------------ + +PCRE is a library of functions to support regular expressions whose syntax +and semantics are as close as possible to those of the Perl 5 language. + +Release 7 of PCRE is distributed under the terms of the "BSD" licence, as +specified below. The documentation for PCRE, supplied in the "doc" +directory, is distributed under the same terms as the software itself. + +The basic library functions are written in C and are freestanding. Also +included in the distribution is a set of C++ wrapper functions. + + +THE BASIC LIBRARY FUNCTIONS +--------------------------- + +Written by: Philip Hazel +Email local part: ph10 +Email domain: cam.ac.uk + +University of Cambridge Computing Service, +Cambridge, England. + +Copyright (c) 1997-2007 University of Cambridge +All rights reserved. + + +THE C++ WRAPPER FUNCTIONS +------------------------- + +Contributed by: Google Inc. + +Copyright (c) 2007, Google Inc. +All rights reserved. + + +THE "BSD" LICENCE +----------------- + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the name of Google + Inc. nor the names of their contributors may be used to endorse or + promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +End + diff --git a/pongr/src/Draw.pbi b/pongr/src/Draw.pbi index 59f27b3..e5b5896 100644 --- a/pongr/src/Draw.pbi +++ b/pongr/src/Draw.pbi @@ -1,16 +1,36 @@ ; Here we draw stuff on screen. These are the dispatch -; functions which wil lbe calles from the state dispatch +; functions which will be called from the state dispatch ; process. + +; Draw the current activated menu. This will be set from +; the dispatcher. The events are controlled by the +; HandleEventMenu() function. Procedure DrawMenu() - DrawText(50, 50, *ActiveMenu\Title, RGB(255, 255, 255), RGB(0, 0, 0)) + Define Black = RGB(0, 0, 0) + Define White = RGB(255, 255, 255) + Define ActiveMenuItemColor = RGB(255, 0, 0) + + DrawText(50, 50, *ActiveMenu\Title, white, black) + Define Offset = 0 + Define FontColor = White + ForEach *ActiveMenu\Entries() + If *ActiveMenu\Entries()\Selected + FontColor = ActiveMenuItemColor + Else + FontColor = White + EndIf + DrawText(50, 300+(Offset*50), *ActiveMenu\Entries()\Label, FontColor, Black) + Offset = Offset+1 + Next EndProcedure + Procedure DrawRunningGame() Box(0, 0, 200, 200, RGB(0, 255, 0)) EndProcedure ; IDE Options = PureBasic 4.51 (Linux - x64) -; CursorPosition = 3 +; CursorPosition = 17 ; Folding = - ; EnableUnicode ; EnableThread diff --git a/pongr/src/Main.pb b/pongr/src/Main.pb index f5fb882..9a33848 100644 --- a/pongr/src/Main.pb +++ b/pongr/src/Main.pb @@ -23,9 +23,26 @@ GameStates("RUNNING_GAME")\HandleEventFun = @HandleEventRunningGame() ; Read the complete game menus from the data/menu.data file. ; TODO: IncludeBinary looks interesting! If ReadFile(0, "../data/menu.data") + CreateRegularExpression(0, "^([A-Z_-]+) {(.*)}") ; Menu title + CreateRegularExpression(1, "^ BUTTON: {(.+)} -> (.+)") ; A button + CreateRegularExpression(2, "^ OPTION: (.*)") ; A option field (TODO: Thats not exactly right) + While Eof(0) = 0 - Debug ReadString(0) + Dim Matches$(0) + Define Line.s = ReadString(0) + + ; We found a new menu + If MatchRegularExpression(0, Line) + Define i + For i=0 To ExtractRegularExpression(0, Line, Matches$())-1 + Debug Matches$(i) ; FIXME: Thats not what we want ... + Next + EndIf Wend + + FreeRegularExpression(0) + FreeRegularExpression(1) + FreeRegularExpression(2) CloseFile(0) EndIf @@ -100,8 +117,8 @@ If OpenWindow(0, 0, 0, Screen\Width, Screen\Height, title, #PB_Window_ScreenCent Until KeyboardPushed(#PB_Key_Escape) EndIf ; IDE Options = PureBasic 4.51 (Linux - x64) -; CursorPosition = 71 -; FirstLine = 52 +; CursorPosition = 37 +; FirstLine = 11 ; EnableXP ; EnableCompileCount = 0 ; EnableBuildCount = 0 \ No newline at end of file