Kigs Framework Introduction (8/8) - Data Driven Application

A multi purpose, cross-platform, free and Open Source C++ framework. Data Driven Application
This article ends the series. We will see an example on how to create a basic application without modifying the C++ code of the template Data Driven Application.

Image 1

Table of Contents

Introduction

Kigs framework proposes a template for Data Driven Applications. Data Driven Applications allow you to navigate between different screens (called Sequences) using mainly XML and/or Lua files. However, the Kigs framework remains a C++ framework and the development of a complete and complex application will probably require the writing of part of the code in C++.

Here is an example of a more complex Data Driven Application based on the Kigs framework:

Fun with YouTube Data API v3 (Public Data) and Kigs Framework

Image 2

Using the Template

See Kigs framework GitHub Getting Started Wiki page for details.

To generate a new Data Driven Application, go to kigs/projects folder and launch (double click) CreateNewDDProject.vbs script. Enter a project name in the dialog box and click OK. Add your project to the CMakeFile.txt, then go to kigs/scripts and launch one of the scripts to generate the desired platform solution.

Overview of a Data Driven Application

A default new Data Driven Application created with the CreateNewDDProject.vbs contains some asset files (data) in kigs/projects/YourProjectName/Android/assets folder. The main files are:

  • AppInit.xml: Contains main window / screen information
  • LaunchScreen.xml: contains the first launched screen (default is a Kigs Logo with fade in/out)
  • Screen_Main.xml: contains the second launched screen (default is a blue screen)

kigs/projects/YourProjectName/Headers folder contains two header files:

  • KigsApplication.h: some defines you generally don't have to edit
  • YourProjectName.h: declaration of the application class

kigs/projects/YourProjectName/Sources folder contains only one file:

  • YourProjectName.cpp: definition of the application class

After adding new files to Headers or Sources folder, use the scripts in kigs/scripts to generate again the desired platform solution.

GlobalConfig File

When the application is launched, a GlobalConfig file is searched and if available, imported. The global config file name is first search for current platform using: GlobalConfig + platform name + .xml.

i.e.,: GlobalConfigWin32.xmlGlobalConfigAndroid.xml ...

If not found, "GlobalConfig.xml" is searched.

This file can be used to create application wide instances. This file is not mandatory. There's no GlobalConfig file in Sample8 example.

AppInit File

AppInit.xml file is mandatory. It is used to initialize Window and RenderingScreen.

Here is the AppInit.xml file used for Sample8:

<?xml version="1.0"?>
<!-- create application window -->
<Inst N="AppWindow" Type="Window">
   <!-- PositionX is from screen left side if positive, centered if -1 
        and from right side if negative ( and not -1 )
	    PositionY is from screen upper side if positive, 
        centered if -1 and from lower side if negative ( and not -1) -->
   <Attr N="PositionX" V="-1"/>
   <Attr N="PositionY" V="-1"/>
   <Attr N="SizeX" V="960"/>
   <Attr N="SizeY" V="600"/>
   <Attr N="FullScreen" V="false"/>
   <Attr N="Mouse Cursor" V="true"/>
   <!-- create rendering screen ( <=> rendering surface ) -->
   <Inst N="theRenderingScreen" Type="RenderingScreen">
      <Attr N="SizeX" V="0">
         <!-- retrieve Window size X -->
         <Modifier Type="CoreItemOperatorModifier" V="#..->SizeX#"/>
      </Attr>
      <Attr N="SizeY" V="0">
         <!-- retrieve Window size Y -->
         <Modifier Type="CoreItemOperatorModifier" V="#..->SizeY#"/>
      </Attr>
      <!-- virtual screen size if 1280*800 -->
      <Attr N="DesignSizeX" V="1280"/>
      <Attr N="DesignSizeY" V="800"/>
      <Attr N="BitsPerZ" V="32"/>
      <Attr N="Brightness" V="0"/>
      <Attr N="BackDropColor" V="{0.0,0.0,0.0}"/>
      <Attr N="VSync" V="true"/>
   </Inst>
   <!-- initialize localizations -->
   <Attr T="string" N="LocalizationInitFile" V="InitLoc.json" Dyn="true"/>
</Inst>

Some options can be set through dynamic attributes on Window instance:

FirstSequenceFile

<Attr T="string" N="FirstSequenceFile" V="FirstSequence.xml" Dyn="true"/>

XML File containing the first sequence to launch (default is "LaunchScreen.xml").

BundleFileName

Bundle file can be used to indicate the path of a file using its name (not detailed here).

<Attr T="string" N="BundleFileName" V="files.bundle" Dyn="true"/>

FilePathManagerInitFile

File used to init FilePathManager (not detailed here).

<Attr T="string" N="FilePathManagerInitFile" V="FilePathManager.json" Dyn="true"/>

LocalizationInitFile

Initialization file for localization manager (not detailed here, but Sample8 manages some localizations).

<Attr T="string" N="LocalizationInitFile" V="Localization.json" Dyn="true"/>

PackageFileName

Load given package file (not detailed here).

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

<Attr T="string" N="PackageFileName" V="package.kpkg" Dyn="true"/>

Sequences

Sequences can be seen as different sections of the application. A video game application for example, can have a splash screen, then an introduction, then a menu screen giving access to a parameter screen, the game itself and a credit screen. Each of those will be a sequence (or several sequences) in a Kigs Data Driven application.

Simple sequence can only be defined by a UI2DLayer. Here is the default splash screen:

<?xml version="1.0"?>
<Inst N="UILayer" T="UI2DLayer">
   <Attr N="SizeY" V="800"/>
   <Attr N="SizeX" V="1280"/>
   <Attr N="Priority" V="0"/>
   <Attr N="RenderingScreen" V="RenderingScreen:theRenderingScreen"/>
   <Inst N="Interface" T="UIItem">
      <Attr N="SizeY" V="800"/>
      <Attr N="SizeX" V="1280"/>
      <Attr N="Opacity" V="0.0"/>
      <Attr N="Dock" V="{0.500000,0.50000}"/>
      <Attr N="Anchor" V="{0.500000,0.50000}"/>
      <Inst N="Logo" T="UIImage">
         <Attr N="Texture" V="Logo.png"/>
         <Attr N="SizeY" V="800"/>
         <Attr N="SizeX" V="1280"/>
         <Attr N="Priority" V="50"/>
         <Attr N="Dock" V="{0.500000,0.50000}"/>
         <Attr N="Anchor" V="{0.500000,0.50000}"/>
         <Attr N="KeepRatio" V="false"/>
      </Inst>
   </Inst>
   <Inst N="FadeIn_Launcher" T="CoreSequenceLauncher">
      <Attr N="StartOnFirstUpdate" V="true"/>
      <Attr N="Sequence">
      <![CDATA[{
      "Fade":[
            {"Linear1D":[0.5,-16,0,"/theRenderingScreen->Brightness",0]},
            { "Wait" : [  0.1 ] },
            { "Notification" :  [ 0 , "StackSequence", "Screen_Main.xml" ] }
         ]
      }
      ]]>
      </Attr>
   </Inst>
</Inst>

More complex sequences are generally defined as DataDrivenSequence.

DataDrivenSequence can have several UI2DLayer and/or Scene3D children, and manage transition between sequences.

Here is a Sample8 first sequence (after splash screen) Screen_Main.xml.

Transitions

DataDrivenTransition can be added to DataDrivenSequence to determine transition effect when going from one sequence to another.

Here is a simple "fade to black the previous sequence, then fade from black to the current sequence transition":

<Inst N="transition" T="DataDrivenTransition">
   <Attr N="PreviousAnim">
   <![CDATA[{
      "Fade":[
      {"Linear1D":[0.5,0,-16,"/theRenderingScreen->Brightness",0]},
      { "SetValue1D" : [0.0,0.0,"Show" ]}
      ]
   }
   ]]>
   </Attr>
   <Attr N="NextAnim">
   <![CDATA[{
      "Fade":[
      { "SetValue1D" : [0.0,0.0,"Show" ]},
      { "Wait" : [  0.5 ] },
      { "SetValue1D" : [0.0,1.0,"Show" ]},
      {"Linear1D":[0.5,-16,0,"/theRenderingScreen->Brightness",0]},
      { "Notification" :  [ 0 , "InitScreen" ] }
      ]
   }
   ]]>
   </Attr>
</Inst>

Sample8 Data Driven Application

The Sample8 Data Driven Application C++ code is exactly the same as the template Data Driven Application. Everything is done in XML / JSON / Lua files in the assets folder.

After splash screen, the first sequence is composed of a 3D scene and a UI2DLayer with some buttons.

Sample 8 first sequence snapshot

A node with an attached spot light is animated:

<Ref P="Node3D:Light" DontAddAsSon="true">
   <!-- Ask this Node3D to be "pivot" controlled --> 
   <Upgrd N="PivotUp"/>
   <!-- the pivot is set in global coordinates --> 
   <Attr N="IsGlobal" V="true"/>
   <!-- around z axis --> 
   <Attr N="PivotAxis" V="{0.000000,0.000000,1.000000}"/>
   <!-- animate pivot angle with an infinite loop --> 
   <Inst Name="animateLightPos" Type="CoreSequenceLauncher">
      <Attr N="Sequence"><![CDATA[
         {"animateLightPos":[
         {"DoWhile":[1,
         {"Linear1D":[4,0,6.28,"Angle"]} ]}
         ]}
         ]]>
      </Attr>
      <!-- animation sequence starts directly -->
      <Attr N="StartOnFirstUpdate" V="true" />
   </Inst>	
</Ref>

A second sequence can be launched by pressing localized "Next" button:

Sample 8 second sequence snapshot

Kigs Tools Embedded Inspector and Editor

When compiled in Debug or ReleaseTools mode, an embedded instance inspector / editor is available by pressing CTRL + F1 keys.

Sample 8 kigs tools

You can inspect all CoreModifiable instances in the application, search them using the Hierarchy / Filter text input.

For example, go to the online Sample8 version, press CTRL+F1, then in the Filter input type "button", then click on "camup_btn" in the list and look at all the button attributes in the "Attributes" window. You can then play with the size, position, color... of the button.

Find all the sample code from this wiki section in Sample8 project (browse the code).

Already Published in this Series

  1. Kigs Framework Introduction (1/8) - Overview
  2. Kigs Framework Introduction (2/8) - CoreModifiable
  3. Kigs Framework Introduction (3/8) - Attributes
  4. Kigs Framework Introduction (4/8) - Methods
  5. Kigs Framework Introduction (5/8) - CoreItem
  6. Kigs Framework Introduction (6/8) - Signal, Slot, Notification
  7. Kigs Framework Introduction (7/8) - Lua Binding
  8. Kigs Framework Introduction (8/8) - Data Driven Application

 

[출처] https://www.codeproject.com/Articles/5271431/Kigs-Framework-Introduction-8-8-Data-Driven-Applic

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
58 [리눅스, Linux] 우분투에서 NTFS 를 Read/Write로 마운트 (듀얼 부팅 화일 공유) file 졸리운_곰 2022.08.13 300
57 [UBUNTU] 우분투 20.04 USB 스틱에 설치 How to Install Ubuntu on a USB Flash Drive file 졸리운_곰 2022.06.02 478
56 [linux mater] Linux passwd : 인증 토큰 수정 오류 졸리운_곰 2022.03.04 353
55 [리눅스 마스터][linux, UNIX] 전설의 라인 에디트 Man page — ED 사용법 졸리운_곰 2021.11.18 356
54 [리눅스 마스터][linux, UNIX] [편집][shell] ed (line editer) 사용예 졸리운_곰 2021.11.17 285
53 [죽기전에 경험해봐야 하는 미니 코어 리눅스 5가지] 5 tiny Linux distros to try before you die file 졸리운_곰 2021.04.25 300
52 [linux] vi 단축키 정리 / vim 학습자료 file 졸리운_곰 2021.04.04 310
51 [linux] VIM Editor 단축키 / 명령어 모음 졸리운_곰 2021.04.04 226
50 [Linux][Crontab] Run Your Flask Regularly Scheduled Jobs with Cron 졸리운_곰 2021.03.20 353
49 [Unix/Linux][유닉스/리눅스] chmod [권한변경] /bin/chmod 졸리운_곰 2021.02.14 247
48 [무료 리눅스 linux 백신, 안티바이러스] 무료 리눅스 백신 ClamAV 이용 및 문제 해결법 졸리운_곰 2021.02.01 342
47 리눅스 tee, 화면과 파일에 동시 출력하기 졸리운_곰 2021.01.21 395
46 [리눅스, Linux] YUM 명령어 정리 file 졸리운_곰 2020.11.07 324
45 [리눅스, linux] 프로세스를 이름으로 단번에 종료하기 졸리운_곰 2020.08.17 497
44 ubuntu 18.04 - Ubuntu 한글 입력기 설치(fcitx) file 졸리운_곰 2020.06.29 334
43 리눅스 파일 찾기 (파일 및 디렉토리 검색) file 졸리운_곰 2020.05.12 277
42 linux desktop 화면 해상도 변경 file 졸리운_곰 2020.04.09 270
41 crontab 저장 파일 위치 졸리운_곰 2020.03.02 321
40 crontab 백업 방법 스크립트 졸리운_곰 2020.03.02 287
39 리눅스 우분투 crontab (크론탭) 설정 졸리운_곰 2020.03.02 281
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED