diff options
author | HyungKyu Song <hk76.song@samsung.com> | 2013-02-15 15:11:20 +0900 |
---|---|---|
committer | HyungKyu Song <hk76.song@samsung.com> | 2013-02-15 15:11:20 +0900 |
commit | dbaa27022052a2ab83beb83cb0ccf16c34ad6188 (patch) | |
tree | 141f0afb75bb97269e2e362c19117ad4b0af0829 | |
parent | 2bf59d371ba83df9a668020165f9b77f47b87614 (diff) | |
download | RockPaperScissors-dbaa27022052a2ab83beb83cb0ccf16c34ad6188.tar.gz RockPaperScissors-dbaa27022052a2ab83beb83cb0ccf16c34ad6188.tar.bz2 RockPaperScissors-dbaa27022052a2ab83beb83cb0ccf16c34ad6188.zip |
Tizen 2.0 Release2.0_release
28 files changed, 1569 insertions, 0 deletions
@@ -0,0 +1,206 @@ +Flora License + +Version 1.0, May, 2012 + +http://www.tizenopensource.org/license + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Compatibility Definition Document +and passes the Compatibility Test Suite as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. + +You may add Your own attribution notices within Derivative Works +that You distribute, alongside or as an addendum to the NOTICE text +from the Work, provided that such additional attribution notices +cannot be construed as modifying the License. You may add Your own +copyright statement to Your modifications and may provide additional or +different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works +as a whole, provided Your use, reproduction, and distribution of +the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.tizenopensource.org/license + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + @@ -0,0 +1,4 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1. +Please, see the LICENSE file for Flora License terms and conditions. + diff --git a/description.xml b/description.xml new file mode 100644 index 0000000..e23d641 --- /dev/null +++ b/description.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<?xml-stylesheet type="text/xsl" href="../../../../description.xsl"?> + +<Overview version="0.17.1"> + <SampleName> RockPaperScissors </SampleName> + <SampleVersion>1.0</SampleVersion> + <Preview>screenshot.png</Preview> + <Description>The RockPaperScissors sample application demonstrates how you can implement a proximity sensor and play the common Rock-Paper-Scissors game.</Description> +</Overview> diff --git a/project/data/nofile.dummy b/project/data/nofile.dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/data/nofile.dummy diff --git a/project/home/nofile.dummy b/project/home/nofile.dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/home/nofile.dummy diff --git a/project/inc/RockPaperScissors.h b/project/inc/RockPaperScissors.h new file mode 100644 index 0000000..06f329f --- /dev/null +++ b/project/inc/RockPaperScissors.h @@ -0,0 +1,76 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _ROCK_PAPER_SCISSORS_H_ +#define _ROCK_PAPER_SCISSORS_H_ + +#include <FApp.h> +#include <FBase.h> +#include <FSystem.h> +#include <FUi.h> + +/** + * [RockPaperScissorsApp] UiApp must inherit from UiApp class + * which provides basic features necessary to define an UiApp. + */ +class RockPaperScissorsApp + : public Tizen::App::UiApp + , public Tizen::System::IScreenEventListener +{ +public: + /** + * [Test] UiApp must have a factory method that creates an instance of itself. + */ + static Tizen::App::UiApp* CreateInstance(void); + +public: + RockPaperScissorsApp(void); + virtual~RockPaperScissorsApp(void); + +public: + // Called when the UiApp is initializing. + bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry); + + // Called when the UiApp initializing is finished. + bool OnAppInitialized(void); + + // Called when the UiApp is requested to terminate. + bool OnAppWillTerminate(void); + + // Called when the UiApp is terminating. + bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false); + + // Called when the UiApp's frame moves to the top of the screen. + void OnForeground(void); + + // Called when this UiApp's frame is moved from top of the screen to the background. + void OnBackground(void); + + // Called when the system memory is not sufficient to run the UiApp any further. + void OnLowMemory(void); + + // Called when the battery level changes. + void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel); + + // Called when the screen turns on. + void OnScreenOn(void); + + // Called when the screen turns off. + void OnScreenOff(void); +}; + +#endif // _ROCK_PAPER_SCISSORS_H_ diff --git a/project/inc/RockPaperScissorsFormFactory.h b/project/inc/RockPaperScissorsFormFactory.h new file mode 100644 index 0000000..f1829bc --- /dev/null +++ b/project/inc/RockPaperScissorsFormFactory.h @@ -0,0 +1,33 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _ROCK_PAPER_SCISSORS_FORM_FACTORY_H_ +#define _ROCK_PAPER_SCISSORS_FORM_FACTORY_H_ + +#include <FUi.h> + +class RockPaperScissorsFormFactory + : public Tizen::Ui::Scenes::IFormFactory +{ +public: + RockPaperScissorsFormFactory(void); + virtual ~RockPaperScissorsFormFactory(void); + + virtual Tizen::Ui::Controls::Form* CreateFormN(const Tizen::Base::String& formId, const Tizen::Ui::Scenes::SceneId& sceneId); +}; + +#endif // _ROCK_PAPER_SCISSORS_FORM_FACTORY_H_ diff --git a/project/inc/RockPaperScissorsFrame.h b/project/inc/RockPaperScissorsFrame.h new file mode 100644 index 0000000..c3fa8d8 --- /dev/null +++ b/project/inc/RockPaperScissorsFrame.h @@ -0,0 +1,36 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _ROCK_PAPER_SCISSORS_FRAME_H_ +#define _ROCK_PAPER_SCISSORS_FRAME_H_ + +#include <FBase.h> +#include <FUi.h> + +class RockPaperScissorsFrame + : public Tizen::Ui::Controls::Frame +{ +public: + RockPaperScissorsFrame(void); + virtual ~RockPaperScissorsFrame(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); +}; + +#endif // _ROCK_PAPER_SCISSORS_FRAME_H_ diff --git a/project/inc/RockPaperScissorsMainForm.h b/project/inc/RockPaperScissorsMainForm.h new file mode 100644 index 0000000..a8518e8 --- /dev/null +++ b/project/inc/RockPaperScissorsMainForm.h @@ -0,0 +1,49 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _ROCK_PAPER_SCISSORS_MAIN_FORM_H_ +#define _ROCK_PAPER_SCISSORS_MAIN_FORM_H_ + +#include <FBase.h> +#include <FUi.h> + +class RockPaperScissorsMainForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Ui::Controls::IFormBackEventListener +{ +public: + RockPaperScissorsMainForm(void); + virtual ~RockPaperScissorsMainForm(void); + bool Initialize(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId); + virtual result OnDraw(void); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); +protected: + static const int ID_BUTTON_START = 101; +}; + +#endif // _ROCK_PAPER_SCISSORS_MAIN_FORM_H_ diff --git a/project/inc/RockPaperScissorsPanelFactory.h b/project/inc/RockPaperScissorsPanelFactory.h new file mode 100644 index 0000000..fc75491 --- /dev/null +++ b/project/inc/RockPaperScissorsPanelFactory.h @@ -0,0 +1,33 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _ROCK_PAPER_SCISSORS_PANEL_FACTORY_H_ +#define _ROCK_PAPER_SCISSORS_PANEL_FACTORY_H_ + +#include <FUi.h> + +class RockPaperScissorsPanelFactory + : public Tizen::Ui::Scenes::IPanelFactory +{ +public: + RockPaperScissorsPanelFactory(void); + virtual ~RockPaperScissorsPanelFactory(void); + + virtual Tizen::Ui::Controls::Panel* CreatePanelN(const Tizen::Base::String& panelId, const Tizen::Ui::Scenes::SceneId& sceneId); +}; + +#endif // _ROCK_PAPER_SCISSORS_PANEL_FACTORY_H_ diff --git a/project/inc/RockPaperScissorsPlayForm.h b/project/inc/RockPaperScissorsPlayForm.h new file mode 100644 index 0000000..68ce8e1 --- /dev/null +++ b/project/inc/RockPaperScissorsPlayForm.h @@ -0,0 +1,76 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _ROCK_PAPER_SCISSORS_PLAY_FORM_H_ +#define _ROCK_PAPER_SCISSORS_PLAY_FORM_H_ + +#include <FBase.h> +#include <FUi.h> +#include <FMedia.h> +#include <FUix.h> + +class RockPaperScissorsPlayForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Ui::Scenes::ISceneEventListener + , public Tizen::Uix::Sensor::ISensorEventListener + , public Tizen::Base::Runtime::ITimerEventListener +{ +public: + RockPaperScissorsPlayForm(void); + virtual ~RockPaperScissorsPlayForm(void); + + bool Initialize(void); + bool InitTimer(void); + bool RegisterSensor(void); + bool UnRegisterSensor(void); + bool InitButton(void); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId); + + virtual result OnDraw(void); + virtual void OnDataReceived(Tizen::Uix::Sensor::SensorType sensorType, Tizen::Uix::Sensor::SensorData& sensorData, result r); + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + +private: + result GetFileList(Tizen::Base::String dirPath); + result AddElementInFileList(Tizen::Base::Collection::ArrayList& fileList, Tizen::Base::String& dirPath, Tizen::Io::DirEntry& DirEntry); + void StartTimer(int interval); + void StopTimer(void); + void StartSensor(void); + void StopSensor(void); + +private: + Tizen::Uix::Sensor::SensorManager __sensorMgr; + Tizen::Base::Collection::ArrayList __fileList; + Tizen::Media::Image* __pImage; + Tizen::Base::Runtime::Timer* __pTimer; + bool __proximityOn; + bool __isAppFinished; + int __res1; + int __res2; + int __res3; + int __res4; +}; + +#endif // _ROCK_PAPER_SCISSORS_PLAY_FORM_H_ diff --git a/project/manifest.xml b/project/manifest.xml new file mode 100755 index 0000000..171d637 --- /dev/null +++ b/project/manifest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<Manifest xmlns="http://schemas.tizen.org/2012/12/manifest"> + <Id>$(manifestAppId)</Id> + <Version>3.0.0</Version> + <Type>C++App</Type> + <Author/> + <Descriptions/> + <Requirements/> + <Apps> + <ApiVersion>2.0</ApiVersion> + <Privileges/> + <UiApp Main="True" MenuIconVisible="True" Name="$(projectName)"> + <UiScalability BaseScreenSize="Normal" CoordinateSystem="Logical" LogicalCoordinate="720"/> + <UiTheme SystemTheme="White"/> + <DisplayNames> + <DisplayName Locale="eng-GB">$(projectName)</DisplayName> + </DisplayNames> + <Icons> + <Icon Section="MainMenu" Type="Xhigh">mainmenu.png</Icon> + </Icons> + <AppControls/> + <LaunchConditions/> + <Notifications/> + </UiApp> + </Apps> +</Manifest> diff --git a/project/packaging/org.tizen.RockPaperScissors.spec b/project/packaging/org.tizen.RockPaperScissors.spec new file mode 100755 index 0000000..00d63bb --- /dev/null +++ b/project/packaging/org.tizen.RockPaperScissors.spec @@ -0,0 +1,49 @@ +Name: org.tizen.RockPaperScissors +Summary: RockPaperScissors sample application +Version: 1.2.1.0 +Release: 1 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(osp-appfw) +BuildRequires: pkgconfig(osp-uifw) +BuildRequires: pkgconfig(osp-image) +BuildRequires: pkgconfig(osp-media) +BuildRequires: pkgconfig(osp-net) +BuildRequires: osp-appfw-internal-devel + +%description +RockPaperScissors sample application + +%prep +%setup -q + +%build +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +%ifarch %{ix86} +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%else +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%endif + +# Call make instruction with smp support +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post -p /sbin/ldconfig +APP_ID=y48xd95308 +echo "/usr/etc/package-manager/backend/oap -i /opt/apps/org.tizen."${APP_ID} +/usr/etc/package-manager/backend/oap -i /opt/apps/org.tizen.${APP_ID} + +%postun -p /sbin/ldconfig +APP_ID=y48xd95308 +echo "/usr/etc/package-manager/backend/oap -u "${APP_ID} +/usr/etc/package-manager/backend/oap -u ${APP_ID} + +%files +%defattr(-,root,root,-) +/opt/apps/* diff --git a/project/res/bawi.JPG b/project/res/bawi.JPG Binary files differnew file mode 100644 index 0000000..9854dbb --- /dev/null +++ b/project/res/bawi.JPG diff --git a/project/res/bo.JPG b/project/res/bo.JPG Binary files differnew file mode 100644 index 0000000..5be2372 --- /dev/null +++ b/project/res/bo.JPG diff --git a/project/res/gawi.JPG b/project/res/gawi.JPG Binary files differnew file mode 100644 index 0000000..4d50861 --- /dev/null +++ b/project/res/gawi.JPG diff --git a/project/shared/data/nofile.dummy b/project/shared/data/nofile.dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/shared/data/nofile.dummy diff --git a/project/shared/res/screen-density-xhigh/mainmenu.png b/project/shared/res/screen-density-xhigh/mainmenu.png Binary files differnew file mode 100755 index 0000000..983c883 --- /dev/null +++ b/project/shared/res/screen-density-xhigh/mainmenu.png diff --git a/project/shared/trusted/nofile.dummy b/project/shared/trusted/nofile.dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/shared/trusted/nofile.dummy diff --git a/project/src/RockPaperScissors.cpp b/project/src/RockPaperScissors.cpp new file mode 100644 index 0000000..189cde7 --- /dev/null +++ b/project/src/RockPaperScissors.cpp @@ -0,0 +1,116 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "RockPaperScissors.h" +#include "RockPaperScissorsFrame.h" +#include "RockPaperScissorsFormFactory.h" +#include "RockPaperScissorsPanelFactory.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::System; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; + +RockPaperScissorsApp::RockPaperScissorsApp(void) +{ +} + +RockPaperScissorsApp::~RockPaperScissorsApp(void) +{ +} + +UiApp* +RockPaperScissorsApp::CreateInstance(void) +{ + return new RockPaperScissorsApp(); +} + +bool +RockPaperScissorsApp::OnAppInitializing(AppRegistry& appRegistry) +{ + return true; +} + +bool +RockPaperScissorsApp::OnAppInitialized(void) +{ + // Create a Frame + RockPaperScissorsFrame* pRockPaperScissorsFrame = new (std::nothrow) RockPaperScissorsFrame(); + TryReturn(pRockPaperScissorsFrame, false, "RockPaperScissorsFrame creation failed."); + pRockPaperScissorsFrame->Construct(); + pRockPaperScissorsFrame->SetName(L"RockPaperScissors"); + AddFrame(*pRockPaperScissorsFrame); + + // Prepare Scene management. + SceneManager* pSceneManager = SceneManager::GetInstance(); + static RockPaperScissorsFormFactory formFactory; + static RockPaperScissorsPanelFactory panelFactory; + pSceneManager->RegisterFormFactory(formFactory); + pSceneManager->RegisterPanelFactory(panelFactory); + pSceneManager->RegisterScene(L"MainScene", L"MainForm", L""); + pSceneManager->RegisterScene(L"PlayScene", L"PlayForm", L""); + + // Goto the scene. + if (pSceneManager->GoForward(ForwardSceneTransition(L"MainScene")) != E_SUCCESS) + return false; + + return true; +} + +bool +RockPaperScissorsApp::OnAppWillTerminate(void) +{ + return true; +} + +bool +RockPaperScissorsApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) +{ + return true; +} + +void +RockPaperScissorsApp::OnForeground(void) +{ +} + +void +RockPaperScissorsApp::OnBackground(void) +{ +} + +void +RockPaperScissorsApp::OnLowMemory(void) +{ +} + +void +RockPaperScissorsApp::OnBatteryLevelChanged(BatteryLevel batteryLevel) +{ +} + +void +RockPaperScissorsApp::OnScreenOn(void) +{ +} + +void +RockPaperScissorsApp::OnScreenOff(void) +{ +} diff --git a/project/src/RockPaperScissorsEntry.cpp b/project/src/RockPaperScissorsEntry.cpp new file mode 100644 index 0000000..b797f27 --- /dev/null +++ b/project/src/RockPaperScissorsEntry.cpp @@ -0,0 +1,64 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * This file contains the Tizen application entry point. + */ +#include "RockPaperScissors.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +_EXPORT_ int OspMain(int argc, char *pArgv[]); + +/** + * The entry function of Tizen application called by the operating system. + */ +int +OspMain(int argc, char *pArgv[]) +{ + result r = E_SUCCESS; + + AppLog("Application started."); + ArrayList* pArgs = new ArrayList(); + pArgs->Construct(); + for (int i = 0; i < argc; i++) + { + pArgs->Add(*(new String(pArgv[i]))); + } + + r = Tizen::App::UiApp::Execute(RockPaperScissorsApp::CreateInstance, pArgs); + if (IsFailed(r)) + { + AppLogException("Application execution failed-[%s].", GetErrorMessage(r)); + r &= 0x0000FFFF; + } + + pArgs->RemoveAll(true); + delete pArgs; + AppLog("Application finished."); + + return static_cast<int>(r); +} +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/project/src/RockPaperScissorsFormFactory.cpp b/project/src/RockPaperScissorsFormFactory.cpp new file mode 100644 index 0000000..ec3b4dd --- /dev/null +++ b/project/src/RockPaperScissorsFormFactory.cpp @@ -0,0 +1,62 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include <new> +#include "RockPaperScissorsFormFactory.h" +#include "RockPaperScissorsMainForm.h" +#include "RockPaperScissorsPlayForm.h" + +using namespace Tizen::Ui::Scenes; + +RockPaperScissorsFormFactory::RockPaperScissorsFormFactory(void) +{ +} + +RockPaperScissorsFormFactory::~RockPaperScissorsFormFactory(void) +{ +} + +Tizen::Ui::Controls::Form* +RockPaperScissorsFormFactory::CreateFormN(const Tizen::Base::String& formId, const Tizen::Ui::Scenes::SceneId& sceneId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + Tizen::Ui::Controls::Form* pNewForm = null; + + if (formId == L"MainForm") + { + RockPaperScissorsMainForm* pForm = new (std::nothrow) RockPaperScissorsMainForm(); + TryReturn(pForm, null, "[%s] RockPaperScissorsMainForm creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else if (formId == L"PlayForm") + { + RockPaperScissorsPlayForm* pForm = new (std::nothrow) RockPaperScissorsPlayForm(); + TryReturn(pForm, null, "[%s] RockPaperScissorsPlayForm creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + pForm->Initialize(); + pSceneManager->AddSceneEventListener(sceneId, *pForm); + pNewForm = pForm; + } + else + { + AppAssert(false); + } + + return pNewForm; +} diff --git a/project/src/RockPaperScissorsFrame.cpp b/project/src/RockPaperScissorsFrame.cpp new file mode 100644 index 0000000..55d6bc5 --- /dev/null +++ b/project/src/RockPaperScissorsFrame.cpp @@ -0,0 +1,44 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "RockPaperScissorsFrame.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +RockPaperScissorsFrame::RockPaperScissorsFrame(void) +{ +} + +RockPaperScissorsFrame::~RockPaperScissorsFrame(void) +{ +} + +result +RockPaperScissorsFrame::OnInitializing(void) +{ + return E_SUCCESS; +} + +result +RockPaperScissorsFrame::OnTerminating(void) +{ + return E_SUCCESS; +} + + diff --git a/project/src/RockPaperScissorsMainForm.cpp b/project/src/RockPaperScissorsMainForm.cpp new file mode 100644 index 0000000..56c06e6 --- /dev/null +++ b/project/src/RockPaperScissorsMainForm.cpp @@ -0,0 +1,183 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include <new> +#include <FApp.h> +#include <FGraphics.h> +#include "RockPaperScissorsMainForm.h" + +using namespace Tizen::Base; +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Graphics; + + +RockPaperScissorsMainForm::RockPaperScissorsMainForm(void) +{ +} + +RockPaperScissorsMainForm::~RockPaperScissorsMainForm(void) +{ +} + +bool +RockPaperScissorsMainForm::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL|FORM_STYLE_HEADER|FORM_STYLE_FOOTER|FORM_STYLE_INDICATOR); + SetName(L"MainForm"); + + // Set Header title + Header* pHeader = this->GetHeader(); + pHeader->SetTitleText(L"ROCK PAPER SCISSORS"); + + Footer* pFooter = this->GetFooter(); + pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT); + pFooter->SetBackButton(); + this->SetFormBackEventListener(this); + + return true; +} + +result +RockPaperScissorsMainForm::OnInitializing(void) +{ + Button *pStartButton = new (std::nothrow) Button(); + TryReturn(pStartButton != null, E_OUT_OF_MEMORY, "[%s] StartButton creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + Rectangle clientAreaBound = GetClientAreaBounds(); + int buttonX = static_cast<int>(clientAreaBound.width * 0.33); + int buttonY = static_cast<int>(clientAreaBound.height * 0.75); + int buttonWidth = static_cast<int>(clientAreaBound.width * 0.34); + int buttonHeight = static_cast<int>(clientAreaBound.height * 0.14); + + pStartButton->Construct(Rectangle(buttonX, buttonY, buttonWidth, buttonHeight)); + pStartButton->SetText(L"Start"); + pStartButton->SetActionId(ID_BUTTON_START); + pStartButton->AddActionEventListener(*this); + AddControl(*pStartButton); + + return E_SUCCESS; +} + +result +RockPaperScissorsMainForm::OnTerminating(void) +{ + return E_SUCCESS; +} + +void +RockPaperScissorsMainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + + switch(actionId) + { + case ID_BUTTON_START: + AppAssert(pSceneManager->GoForward(ForwardSceneTransition(L"PlayScene")) == E_SUCCESS); + break; + + default: + break; + } +} + +void +RockPaperScissorsMainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + AppLog("RockPaperScissorsMainForm activated"); +} + +void +RockPaperScissorsMainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ + AppLog("RockPaperScissorsMainForm deactivated"); +} + +result +RockPaperScissorsMainForm::OnDraw(void) +{ + Tizen::Graphics::Canvas* pCanvas = GetCanvasN(); + + if(pCanvas != null) + { + // Rectangle + static Rectangle clientAreaBound = GetClientAreaBounds(); + static int rectMarginX = static_cast<int>(clientAreaBound.width * 0.03); + static int rectMarginY = static_cast<int>(clientAreaBound.height * 0.25); + static int rectX = clientAreaBound.x + rectMarginX; + static int rectY = clientAreaBound.y + rectMarginY; + static int rectWidth = clientAreaBound.width - (rectMarginX * 2); + static int rectHeight = static_cast<int>(clientAreaBound.height * 0.45); + static int titleHeight = static_cast<int>(rectHeight * 0.167); + // Font size + static int HEAD_FONT_SIZE = static_cast<int>(titleHeight * 0.7); + static int BODY_FONT_SIZE = static_cast<int>(titleHeight * 0.45); + // Line + static int lineStartX = rectX; + static int lineEndX = lineStartX + rectWidth; + static int lineY = rectY + titleHeight; + // Headline + static int headX = rectX; + static int headY = rectY; + // Text + static int textX = headX + rectMarginX; + static int textY = lineY + rectMarginX; + static int textGapY = BODY_FONT_SIZE + rectMarginX; + static String text0(L"<How to play this game>"); + static String text1(L"This game can join up to 4 people."); + static String text2(L"1. Choose the number."); + static String text3(L"2. Press the start button."); + static String text4(L"3. To stop, place a hand"); + static String text5(L"across & near the top of the phone."); + + pCanvas->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK)); + pCanvas->SetForegroundColor(Color::GetColor(COLOR_ID_YELLOW)); + pCanvas->Clear(); + + Font headFont; + headFont.Construct(FONT_STYLE_PLAIN || FONT_STYLE_BOLD, HEAD_FONT_SIZE); + pCanvas->SetFont(headFont); + pCanvas->DrawRectangle(Rectangle(rectX, rectY, rectWidth, rectHeight)); + pCanvas->DrawText(Point(headX, headY), text0); + pCanvas->DrawLine(Point(lineStartX, lineY), Point(lineEndX, lineY)); + + Font bodyFont; + bodyFont.Construct(FONT_STYLE_PLAIN, BODY_FONT_SIZE); + pCanvas->SetFont(bodyFont); + pCanvas->DrawText(Point(headX, textY), text1); + pCanvas->DrawText(Point(textX, textY + textGapY), text2); + pCanvas->DrawText(Point(textX, textY + (textGapY * 2)), text3); + pCanvas->DrawText(Point(textX, textY + (textGapY * 3)), text4); + pCanvas->DrawText(Point(textX, textY + (textGapY * 4)), text5); + + delete pCanvas; + } + + return E_SUCCESS; +} +void +RockPaperScissorsMainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + UiApp* pApp = UiApp::GetInstance(); + AppAssert(pApp); + pApp->Terminate(); +} diff --git a/project/src/RockPaperScissorsPanelFactory.cpp b/project/src/RockPaperScissorsPanelFactory.cpp new file mode 100644 index 0000000..a448143 --- /dev/null +++ b/project/src/RockPaperScissorsPanelFactory.cpp @@ -0,0 +1,40 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "RockPaperScissorsPanelFactory.h" +#include <FUi.h> + +using namespace Tizen::Ui::Scenes; + + +RockPaperScissorsPanelFactory::RockPaperScissorsPanelFactory(void) +{ +} + +RockPaperScissorsPanelFactory::~RockPaperScissorsPanelFactory(void) +{ +} + +Tizen::Ui::Controls::Panel* +RockPaperScissorsPanelFactory::CreatePanelN(const Tizen::Base::String& panelId, const Tizen::Ui::Scenes::SceneId& sceneId) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + Tizen::Ui::Controls::Panel* pNewPanel = null; + + return pNewPanel; +} diff --git a/project/src/RockPaperScissorsPlayForm.cpp b/project/src/RockPaperScissorsPlayForm.cpp new file mode 100644 index 0000000..b3dde96 --- /dev/null +++ b/project/src/RockPaperScissorsPlayForm.cpp @@ -0,0 +1,426 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.org/license +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include <new> +#include <FApp.h> +#include <FIo.h> +#include <FSystem.h> +#include "RockPaperScissorsPlayForm.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Scenes; +using namespace Tizen::Uix::Sensor; +using namespace Tizen::Graphics; +using namespace Tizen::Io; +using namespace Tizen::System; +using namespace Tizen::Media; + +static const int TIMERINTERVAL = 200; +static const int IMAGE_COUNT = 3; +static const wchar_t IMAGE_EXT[] = L"jpg"; + +RockPaperScissorsPlayForm::RockPaperScissorsPlayForm(void) + : __sensorMgr() + , __fileList() + , __pImage(null) + , __pTimer(null) + , __proximityOn(false) + , __isAppFinished(false) + , __res1(0) + , __res2(0) + , __res3(0) + , __res4(0) +{ + __fileList.Construct(); +} + +RockPaperScissorsPlayForm::~RockPaperScissorsPlayForm(void) +{ + __fileList.RemoveAll(true); +} + +bool +RockPaperScissorsPlayForm::Initialize(void) +{ + // Set Form properties + Form::Construct(FORM_STYLE_HEADER|FORM_STYLE_FOOTER|FORM_STYLE_INDICATOR); + SetName(L"RockPaperScissorsForm"); + + // about Header + Header* pHeader = this->GetHeader(); + pHeader->SetTitleText(L"ROCK PAPER SCISSORS"); + + // about Footer + Footer* pFooter = this->GetFooter(); + pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT); + pFooter->SetBackButton(); + + this->SetFormBackEventListener(this); + + return true; +} + +result +RockPaperScissorsPlayForm::OnInitializing(void) +{ + __sensorMgr.Construct(); + + if (!__sensorMgr.IsAvailable(SENSOR_TYPE_PROXIMITY)) + { + AppLog("[Fail]PROXIMITY Sensor does not supported. This sample cannot be activated."); + + Application::GetInstance()->Terminate(); + + return E_FAILURE; + } + + + result r = GetFileList(App::GetInstance()->GetAppRootPath() + String(L"res/")); + TryReturn(!IsFailed(r), r, "[Fail]FileList Get"); + + __pImage = new (std::nothrow) Image(); + TryReturn(__pImage != null, E_FAILURE, "[Fail]Image Create"); + + __pImage->Construct(); + + + return E_SUCCESS; +} + +result +RockPaperScissorsPlayForm::OnTerminating(void) +{ + __proximityOn = false; + + if (!__isAppFinished) + { + __isAppFinished = true; + StopTimer(); + StopSensor(); + } + + if (__pImage != null) + { + delete __pImage; + } + + return E_SUCCESS; +} + +void +RockPaperScissorsPlayForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + SceneManager* pSceneManager = SceneManager::GetInstance(); + AppAssert(pSceneManager); + AppAssert(pSceneManager->GoBackward(BackwardSceneTransition("MainScene")) == E_SUCCESS); +} + +void +RockPaperScissorsPlayForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) +{ + AppLog("MetalDetectorDetectForm activated"); + InitTimer(); + StartSensor(); + StartTimer(TIMERINTERVAL); +} + +void +RockPaperScissorsPlayForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) +{ + AppLog("MetalDetectorDetectForm deactivated"); + StopSensor(); + StopTimer(); + __proximityOn=false; + __isAppFinished=false; +} + +result +RockPaperScissorsPlayForm::OnDraw(void) +{ + int imgCount = __fileList.GetCount(); + int startX, startY, midX, midY, endX, endY; + Rectangle rect; + + if (!__proximityOn && !__isAppFinished) + { + __res1 = static_cast<unsigned int>(Math::Rand()) % imgCount; + __res2 = static_cast<unsigned int>(Math::Rand()) % imgCount; + __res3 = static_cast<unsigned int>(Math::Rand()) % imgCount; + __res4 = static_cast<unsigned int>(Math::Rand()) % imgCount; + } + // canvas + Tizen::Graphics::Canvas* __pCanvas = GetCanvasN(); + if (__pCanvas != null) + { + __pCanvas->SetBackgroundColor(Color::GetColor(COLOR_ID_YELLOW)); + __pCanvas->SetForegroundColor(Color::GetColor(COLOR_ID_BLACK)); + __pCanvas->Clear(); + + // get img name + String* imageName1 = static_cast<String*>(__fileList.GetAt(__res1)); + String* imageName2 = static_cast<String*>(__fileList.GetAt(__res2)); + String* imageName3 = static_cast<String*>(__fileList.GetAt(__res3)); + String* imageName4 = static_cast<String*>(__fileList.GetAt(__res4)); + if (imageName1 == null || imageName2 == null || imageName3 == null || imageName4 == null) + { + delete __pCanvas; + return E_FILE_NOT_FOUND; + } + + // get bitmap + Bitmap* pBmp1 = __pImage->DecodeN(*imageName1, BITMAP_PIXEL_FORMAT_ARGB8888); + Bitmap* pBmp2 = __pImage->DecodeN(*imageName2, BITMAP_PIXEL_FORMAT_ARGB8888); + Bitmap* pBmp3 = __pImage->DecodeN(*imageName3, BITMAP_PIXEL_FORMAT_ARGB8888); + Bitmap* pBmp4 = __pImage->DecodeN(*imageName4, BITMAP_PIXEL_FORMAT_ARGB8888); + if ((pBmp1 != null) && (pBmp2 != null) && (pBmp3 != null) && (pBmp4 != null)) + { + rect = GetClientAreaBounds(); + rect.x += 5; + rect.y += 5; + rect.width -= 10; + rect.height -= 20; + __pCanvas->SetLineWidth(3); + __pCanvas->DrawRectangle(rect); + + startX = rect.x; + startY = rect.y + 30; + midX = rect.x + (rect.width / 2); + midY = rect.y + (rect.height / 2); + endX = rect.x + rect.width; + endY = rect.y + rect.height; + + // font + Font font; + font.Construct(FONT_STYLE_PLAIN, static_cast<int>((startY - rect.y) * 0.55)); + __pCanvas->SetFont(font); + + // draw Line + __pCanvas->SetLineWidth(3); + __pCanvas->DrawLine(Point(startX, startY), Point(endX, startY)); + __pCanvas->DrawLine(Point(startX, midY), Point(endX, midY)); + __pCanvas->DrawLine(Point(startX, endY), Point(endX, endY)); + __pCanvas->DrawLine(Point(midX, startY), Point(midX, endY)); + + // draw Text & bitmap + if (!__proximityOn && !__isAppFinished) + { + __pCanvas->DrawText(Point(rect.x+3, rect.y+5), L"To stop, place a hand across & near the top of the phone."); + } + else + { + __pCanvas->DrawText(Point(rect.x+3, rect.y+5), L"Result"); + } + + __pCanvas->DrawText(Point(startX + 5, startY + 5), L"<<1>>"); + __pCanvas->DrawBitmap(Rectangle(startX + 5, startY + 30, rect.width / 2 - 10, rect.height / 2 - 65), *pBmp1); + + __pCanvas->DrawText(Point(midX + 5, startY + 5), L"<<2>>"); + __pCanvas->DrawBitmap(Rectangle(midX + 5, startY + 30, rect.width / 2 - 10, rect.height / 2 - 65), *pBmp2); + + __pCanvas->DrawText(Point(startX + 5, midY + 5), L"<<3>>"); + __pCanvas->DrawBitmap(Rectangle(startX + 5, midY + 30, rect.width / 2 - 10, rect.height / 2 - 65), *pBmp3); + + __pCanvas->DrawText(Point(midX + 5, midY + 5), L"<<4>>"); + __pCanvas->DrawBitmap(Rectangle(midX + 5, midY + 30, rect.width / 2 - 10, rect.height / 2 - 65), *pBmp4); + + } + if (pBmp1 != null) + { + delete pBmp1; + } + if (pBmp2 != null) + { + delete pBmp2; + } + if (pBmp3 != null) + { + delete pBmp3; + } + if (pBmp4 != null) + { + delete pBmp4; + } + } + delete __pCanvas; + + if (!__isAppFinished) + { + if (__proximityOn) + { + StopTimer(); + StopSensor(); + } + else + { + StartTimer(TIMERINTERVAL); + } + } + else + { + AppLogException("Abnormal case!!!"); + } + + return E_SUCCESS; +} + +void +RockPaperScissorsPlayForm::OnDataReceived(SensorType sensorType, SensorData& sensorData, result r) +{ + TryReturnVoid(!IsFailed(r), "[%s] Invalid sensor data.", GetErrorMessage(r)); + + bool bOnOff = false; + sensorData.GetValue(static_cast<SensorDataKey>(PROXIMITY_DATA_KEY_ONOFF), bOnOff); + AppLog("DataReceived: Get Proximity Sensor Data[%s]", (bOnOff) ? "On" : "Off"); + __proximityOn = bOnOff; +} + +bool +RockPaperScissorsPlayForm::InitTimer(void) +{ + __pTimer = new (std::nothrow) Timer(); + TryReturn(__pTimer != null, false, "[Fail]Timer Create"); + + __pTimer->Construct(*this); + + long long tick = 0; + SystemTime::GetTicks(tick); + Math::Srand(static_cast<unsigned int>(tick)); + + return true; +} + +void +RockPaperScissorsPlayForm::StartTimer(int interval) +{ + __pTimer->Start(interval); +} + +void +RockPaperScissorsPlayForm::StopTimer(void) +{ + if (__pTimer != null) + { + __pTimer->Cancel(); + delete __pTimer; + __pTimer = null; + } +} + +void +RockPaperScissorsPlayForm::OnTimerExpired(Timer& timer) +{ + if (!__isAppFinished) + { + RequestRedraw(); + } +} + +void +RockPaperScissorsPlayForm::StartSensor(void) +{ + long interval = 0L; + + AppLog("Activating RockPaperScissors..."); + __sensorMgr.GetMinInterval(SENSOR_TYPE_PROXIMITY, interval); + + if (interval < 200) + { + interval = 200; + } + + __sensorMgr.AddSensorListener(*this, SENSOR_TYPE_PROXIMITY, interval, true); +} + +void +RockPaperScissorsPlayForm::StopSensor(void) +{ + __isAppFinished = true; + + AppLog("Deactivating RockPaperScissors..."); + __sensorMgr.RemoveSensorListener(*this); +} + +result +RockPaperScissorsPlayForm::AddElementInFileList(ArrayList& fileList, String& dirPath, DirEntry& dirEntry) +{ + if (!dirEntry.IsDirectory()) + { + String ext(IMAGE_EXT); + String subStr; + String tempStr(dirPath); + String fileName(dirEntry.GetName()); + + fileName.SubString(fileName.GetLength()-3, 3, subStr); + if (subStr.Equals(ext, false)) + { + tempStr.Append(fileName); + + String* pNewString = new (std::nothrow) String(tempStr); + TryReturn(pNewString != null, E_OUT_OF_MEMORY, "[%s] NewString creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + fileList.Add(*pNewString); + } + } + + return E_SUCCESS; +} + +result +RockPaperScissorsPlayForm::GetFileList(String dirPath) +{ + Directory* pDir = new (std::nothrow) Directory(); + TryReturn(pDir, E_OUT_OF_MEMORY, "[%s] Directory creation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + result r = pDir->Construct(dirPath); + if (IsFailed(r)) + { + delete pDir; + AppLogException("[%s] Directory construction failed.", GetErrorMessage(r)); + return r; + } + + DirEnumerator* pDirEnum = pDir->ReadN(); + if (!pDirEnum) + { + delete pDir; + AppLogException("[%s] Directory reading failed.", GetErrorMessage(r)); + } + + while (pDirEnum->MoveNext() == E_SUCCESS) + { + DirEntry dirEntry = pDirEnum->GetCurrentDirEntry(); + AddElementInFileList(__fileList, dirPath, dirEntry); + } + + delete pDirEnum; + pDirEnum = null; + delete pDir; + pDir = null; + + TryReturn(__fileList.GetCount() == IMAGE_COUNT, E_IO, "[%s] Unexpected IO exception occurred.", GetErrorMessage(E_IO)); + + return E_SUCCESS; +} + diff --git a/sample.xml b/sample.xml new file mode 100644 index 0000000..3b70efd --- /dev/null +++ b/sample.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<template> + + <slp-property> + <property-group> + <sample-name>RockPaperScissors</sample-name> + <category>Sample</category> + <sdk-version>1.00</sdk-version> + <project-type>org.tizen.nativecpp.buildArtefactType.app</project-type> + <sample-description>description.xml</sample-description> + </property-group> + </slp-property> + + <process type="org.tizen.nativeappcommon.TizenCopyFolder"> + <simple name="projectName" value="$(projectName)"/> + <simple name="folderPath" value="project"/> + <complex-array name="replaceableFiles"> + <element> + <simple name="sourcePath" value="manifest.xml"/> + <simple name="targetPath" value="manifest.xml"/> + <simple name="replaceable" value = "true"/> + </element> + </complex-array> + </process> + <process type="org.tizen.nativecpp.SetDefaultFrameworks"> + <simple name="projectName" value="$(projectName)"/> + <complex-array name="frameworkList"> + <element> + <simple name="framework" value="osp"/> + </element> + <element> + <simple name="framework" value="osp-compat"/> + </element> + </complex-array> + </process> + +</template> diff --git a/screenshot.png b/screenshot.png Binary files differnew file mode 100644 index 0000000..d4c369a --- /dev/null +++ b/screenshot.png |