From 775008a513ab9fb821e39bbf7297f6f0f4e0b225 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 17 Dec 2021 20:57:56 -0600 Subject: [PATCH] [nostalgia] Start on new TileSheetEditor --- .liccor.yml | 6 +- CMakeLists.txt | 4 - LICENSE | 373 ------ conanfile.py | 2 +- src/nostalgia/CMakeLists.txt | 9 - src/nostalgia/common/bounds.cpp | 6 +- src/nostalgia/common/bounds.hpp | 7 +- src/nostalgia/common/common.hpp | 6 +- src/nostalgia/common/point.hpp | 7 +- src/nostalgia/common/size.hpp | 7 +- src/nostalgia/core/CMakeLists.txt | 3 +- src/nostalgia/core/assetmanager.hpp | 6 +- src/nostalgia/core/clipboard.hpp | 6 +- src/nostalgia/core/color.hpp | 6 +- src/nostalgia/core/config.hpp | 6 +- src/nostalgia/core/consts.hpp | 6 +- src/nostalgia/core/context.hpp | 6 +- src/nostalgia/core/core.hpp | 6 +- src/nostalgia/core/gba/addresses.hpp | 6 +- src/nostalgia/core/gba/bios.hpp | 6 +- src/nostalgia/core/gba/core.arm.cpp | 6 +- src/nostalgia/core/gba/core.cpp | 6 +- src/nostalgia/core/gba/gfx.cpp | 9 +- src/nostalgia/core/gba/gfx.hpp | 6 +- src/nostalgia/core/gba/irq.arm.cpp | 6 +- src/nostalgia/core/gba/irq.hpp | 6 +- src/nostalgia/core/gba/media.cpp | 6 +- src/nostalgia/core/gba/panic.cpp | 6 +- src/nostalgia/core/gba/tests.cpp | 6 +- src/nostalgia/core/gfx.cpp | 6 +- src/nostalgia/core/gfx.hpp | 8 +- src/nostalgia/core/glfw/clipboard.cpp | 6 +- src/nostalgia/core/glfw/core.cpp | 6 +- src/nostalgia/core/glfw/core.hpp | 6 +- src/nostalgia/core/glfw/gfx.cpp | 8 +- src/nostalgia/core/input.hpp | 6 +- src/nostalgia/core/media.cpp | 6 +- src/nostalgia/core/media.hpp | 6 +- src/nostalgia/core/sdl/core.cpp | 6 +- src/nostalgia/core/sdl/core.hpp | 6 +- src/nostalgia/core/sdl/gfx.cpp | 6 +- src/nostalgia/core/studio/CMakeLists.txt | 60 +- src/nostalgia/core/studio/Pixel.qml | 38 - src/nostalgia/core/studio/Tile.qml | 48 - src/nostalgia/core/studio/TileSheetEditor.qml | 200 --- src/nostalgia/core/studio/consts.hpp | 6 +- src/nostalgia/core/studio/imgconv.cpp | 19 +- src/nostalgia/core/studio/imgconv.hpp | 21 +- .../core/studio/import_tilesheet_wizard.cpp | 6 +- .../core/studio/import_tilesheet_wizard.hpp | 6 +- src/nostalgia/core/studio/module.cpp | 59 +- src/nostalgia/core/studio/module.hpp | 21 +- .../core/studio/new_tilesheet_wizard.cpp | 6 +- .../core/studio/new_tilesheet_wizard.hpp | 6 +- .../core/studio/newpalettewizard.cpp | 6 +- .../core/studio/newpalettewizard.hpp | 6 +- src/nostalgia/core/studio/paletteeditor.cpp | 6 +- src/nostalgia/core/studio/paletteeditor.hpp | 6 +- src/nostalgia/core/studio/ptidxconv.hpp | 55 + src/nostalgia/core/studio/rsrc.qrc | 7 - src/nostalgia/core/studio/tilesheeteditor.cpp | 1068 +---------------- src/nostalgia/core/studio/tilesheeteditor.hpp | 243 +--- .../core/studio/tilesheetpixelgrid.cpp | 90 ++ .../core/studio/tilesheetpixelgrid.hpp | 80 ++ src/nostalgia/core/studio/tilesheetpixels.cpp | 108 ++ src/nostalgia/core/studio/tilesheetpixels.hpp | 59 + src/nostalgia/core/studio/util.cpp | 6 +- src/nostalgia/core/studio/util.hpp | 6 +- src/nostalgia/core/userland/gfx.cpp | 6 +- src/nostalgia/core/userland/gfx.hpp | 6 +- src/nostalgia/core/userland/gfx_opengl.cpp | 6 +- src/nostalgia/core/userland/media.cpp | 6 +- src/nostalgia/glutils/glutils.cpp | 6 +- src/nostalgia/glutils/glutils.hpp | 8 +- src/nostalgia/player/app.cpp | 6 +- src/nostalgia/player/app.hpp | 6 +- src/nostalgia/player/main.cpp | 6 +- src/nostalgia/scene/scene.cpp | 6 +- src/nostalgia/scene/scene.hpp | 6 +- src/nostalgia/studio/CMakeLists.txt | 2 +- src/nostalgia/studio/builtinmodules.hpp | 18 +- src/nostalgia/studio/filedialogmanager.cpp | 6 +- src/nostalgia/studio/filedialogmanager.hpp | 6 +- src/nostalgia/studio/lib/configio.cpp | 6 +- src/nostalgia/studio/lib/configio.hpp | 6 +- src/nostalgia/studio/lib/editor.cpp | 6 +- src/nostalgia/studio/lib/editor.hpp | 6 +- src/nostalgia/studio/lib/filedialog.hpp | 6 +- src/nostalgia/studio/lib/filedialog_gtk.cpp | 6 +- src/nostalgia/studio/lib/module.cpp | 6 +- src/nostalgia/studio/lib/module.hpp | 6 +- src/nostalgia/studio/lib/project.cpp | 6 +- src/nostalgia/studio/lib/project.hpp | 6 +- src/nostalgia/studio/lib/task.cpp | 6 +- src/nostalgia/studio/lib/task.hpp | 6 +- src/nostalgia/studio/lib/undostack.cpp | 6 +- src/nostalgia/studio/lib/undostack.hpp | 6 +- src/nostalgia/studio/lib/widget.cpp | 6 +- src/nostalgia/studio/lib/widget.hpp | 6 +- src/nostalgia/studio/lib/window.cpp | 6 +- src/nostalgia/studio/lib/window.hpp | 6 +- src/nostalgia/studio/main.cpp | 6 +- src/nostalgia/studio/projectexplorer.cpp | 6 +- src/nostalgia/studio/projectexplorer.hpp | 6 +- src/nostalgia/studio/projecttreemodel.cpp | 6 +- src/nostalgia/studio/projecttreemodel.hpp | 6 +- src/nostalgia/studio/studio.hpp | 6 +- src/nostalgia/studio/studioapp.cpp | 54 +- src/nostalgia/studio/studioapp.hpp | 8 +- src/nostalgia/tools/pack.cpp | 6 +- src/nostalgia/tools/pack/pack.cpp | 6 +- src/nostalgia/tools/pack/pack.hpp | 6 +- src/nostalgia/world/studio/consts.cpp | 6 +- src/nostalgia/world/studio/consts.hpp | 6 +- src/nostalgia/world/studio/newworldwizard.cpp | 6 +- src/nostalgia/world/studio/newworldwizard.hpp | 6 +- src/nostalgia/world/studio/worldeditor.cpp | 6 +- src/nostalgia/world/studio/worldeditor.hpp | 6 +- .../world/studio/worldstudioplugin.cpp | 6 +- .../world/studio/worldstudioplugin.hpp | 6 +- src/nostalgia/world/world.cpp | 6 +- src/nostalgia/world/world.hpp | 6 +- 122 files changed, 651 insertions(+), 2592 deletions(-) delete mode 100644 LICENSE delete mode 100644 src/nostalgia/core/studio/Pixel.qml delete mode 100644 src/nostalgia/core/studio/Tile.qml delete mode 100644 src/nostalgia/core/studio/TileSheetEditor.qml create mode 100644 src/nostalgia/core/studio/ptidxconv.hpp delete mode 100644 src/nostalgia/core/studio/rsrc.qrc create mode 100644 src/nostalgia/core/studio/tilesheetpixelgrid.cpp create mode 100644 src/nostalgia/core/studio/tilesheetpixelgrid.hpp create mode 100644 src/nostalgia/core/studio/tilesheetpixels.cpp create mode 100644 src/nostalgia/core/studio/tilesheetpixels.hpp diff --git a/.liccor.yml b/.liccor.yml index e3abb5b9..72dae978 100644 --- a/.liccor.yml +++ b/.liccor.yml @@ -2,8 +2,4 @@ source: - src copyright_notice: |- - Copyright 2016 - 2021 gary@drinkingtea.net - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. + Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. diff --git a/CMakeLists.txt b/CMakeLists.txt index 1228acaa..e5320ba4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,6 @@ else() include(${NOSTALGIA_CONAN_PATHS}) endif() set(CMAKE_POSITION_INDEPENDENT_CODE ON) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR}) endif() if(APPLE) @@ -33,9 +32,6 @@ if(APPLE) set(NOSTALGIA_DIST_MAC_APP_CONTENTS nostalgia-studio.app/Contents) else() set(CMAKE_INSTALL_RPATH "$ORIGIN" "$ORIGIN/../lib/ox" "$ORIGIN/../lib/nostalgia" "$ORIGIN/../") - if(QTDIR) - set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} "${QTDIR}/lib") - endif() set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(NOSTALGIA_DIST_BIN bin) set(NOSTALGIA_DIST_LIB lib) diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 14e2f777..00000000 --- a/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/conanfile.py b/conanfile.py index 35a261d2..699eb13f 100644 --- a/conanfile.py +++ b/conanfile.py @@ -2,7 +2,7 @@ from conans import ConanFile, CMake class NostalgiaConan(ConanFile): settings = 'os', 'compiler', 'build_type', 'arch' - requires = 'jsoncpp/1.9.4', 'glfw/3.3.4', 'imgui/1.82' + requires = 'jsoncpp/1.9.4', 'glfw/3.3.4', 'imgui/1.83' generators = 'cmake', 'cmake_find_package', 'cmake_paths' default_options = { } diff --git a/src/nostalgia/CMakeLists.txt b/src/nostalgia/CMakeLists.txt index ce3b0e40..c0052c33 100644 --- a/src/nostalgia/CMakeLists.txt +++ b/src/nostalgia/CMakeLists.txt @@ -1,13 +1,4 @@ -#setup libraries - -if(NOSTALGIA_BUILD_TYPE STREQUAL "Native") - if(NOSTALGIA_BUILD_STUDIO) - find_package(QT NAMES Qt6 Qt5 COMPONENTS QuickWidgets Widgets REQUIRED) - find_package(Qt${QT_VERSION_MAJOR} COMPONENTS QuickWidgets Widgets REQUIRED) - endif() -endif() - #project packages add_subdirectory(core) diff --git a/src/nostalgia/common/bounds.cpp b/src/nostalgia/common/bounds.cpp index 1d9539f2..7c19bfe2 100644 --- a/src/nostalgia/common/bounds.cpp +++ b/src/nostalgia/common/bounds.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "bounds.hpp" diff --git a/src/nostalgia/common/bounds.hpp b/src/nostalgia/common/bounds.hpp index 65aa5feb..9eedd383 100644 --- a/src/nostalgia/common/bounds.hpp +++ b/src/nostalgia/common/bounds.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -16,7 +12,6 @@ class Bounds { public: static constexpr auto TypeName = "net.drinkingtea.nostalgia.common.Bounds"; - static constexpr auto Fields = 4; static constexpr auto TypeVersion = 1; int x = 0; int y = 0; diff --git a/src/nostalgia/common/common.hpp b/src/nostalgia/common/common.hpp index 76143090..b570ec19 100644 --- a/src/nostalgia/common/common.hpp +++ b/src/nostalgia/common/common.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/common/point.hpp b/src/nostalgia/common/point.hpp index fac91d66..cafceec7 100644 --- a/src/nostalgia/common/point.hpp +++ b/src/nostalgia/common/point.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -15,7 +11,6 @@ namespace nostalgia::common { class Point { public: static constexpr auto TypeName = "net.drinkingtea.nostalgia.common.Point"; - static constexpr auto Fields = 2; static constexpr auto TypeVersion = 1; int x = 0; int y = 0; diff --git a/src/nostalgia/common/size.hpp b/src/nostalgia/common/size.hpp index deb00685..ae6be3db 100644 --- a/src/nostalgia/common/size.hpp +++ b/src/nostalgia/common/size.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -15,7 +11,6 @@ namespace nostalgia::common { class Size { public: static constexpr auto TypeName = "net.drinkingtea.nostalgia.common.Size"; - static constexpr auto Fields = 2; static constexpr auto TypeVersion = 1; int width = 0; int height = 0; diff --git a/src/nostalgia/core/CMakeLists.txt b/src/nostalgia/core/CMakeLists.txt index 73de3f3e..96d3c861 100644 --- a/src/nostalgia/core/CMakeLists.txt +++ b/src/nostalgia/core/CMakeLists.txt @@ -17,10 +17,11 @@ target_link_libraries( add_subdirectory(gba) if(NOSTALGIA_BUILD_TYPE STREQUAL "Native") add_subdirectory(glfw) + #add_subdirectory(sdl) add_subdirectory(userland) endif() if(NOSTALGIA_BUILD_STUDIO) - #add_subdirectory(studio) + add_subdirectory(studio) endif() install( diff --git a/src/nostalgia/core/assetmanager.hpp b/src/nostalgia/core/assetmanager.hpp index 9e0bdbb7..0f3e2527 100644 --- a/src/nostalgia/core/assetmanager.hpp +++ b/src/nostalgia/core/assetmanager.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/clipboard.hpp b/src/nostalgia/core/clipboard.hpp index 579c4958..70c86653 100644 --- a/src/nostalgia/core/clipboard.hpp +++ b/src/nostalgia/core/clipboard.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/color.hpp b/src/nostalgia/core/color.hpp index ea23324d..8238ee29 100644 --- a/src/nostalgia/core/color.hpp +++ b/src/nostalgia/core/color.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/config.hpp b/src/nostalgia/core/config.hpp index b519941f..e9c8676e 100644 --- a/src/nostalgia/core/config.hpp +++ b/src/nostalgia/core/config.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/consts.hpp b/src/nostalgia/core/consts.hpp index 24a6cda6..df230c66 100644 --- a/src/nostalgia/core/consts.hpp +++ b/src/nostalgia/core/consts.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/context.hpp b/src/nostalgia/core/context.hpp index 01cb2543..138b3106 100644 --- a/src/nostalgia/core/context.hpp +++ b/src/nostalgia/core/context.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/core.hpp b/src/nostalgia/core/core.hpp index a5064d94..b86da5d5 100644 --- a/src/nostalgia/core/core.hpp +++ b/src/nostalgia/core/core.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/gba/addresses.hpp b/src/nostalgia/core/gba/addresses.hpp index 18de77be..ffa46e46 100644 --- a/src/nostalgia/core/gba/addresses.hpp +++ b/src/nostalgia/core/gba/addresses.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/gba/bios.hpp b/src/nostalgia/core/gba/bios.hpp index de03355c..1d48d3f8 100644 --- a/src/nostalgia/core/gba/bios.hpp +++ b/src/nostalgia/core/gba/bios.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/gba/core.arm.cpp b/src/nostalgia/core/gba/core.arm.cpp index 47398d21..925a5e78 100644 --- a/src/nostalgia/core/gba/core.arm.cpp +++ b/src/nostalgia/core/gba/core.arm.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/gba/core.cpp b/src/nostalgia/core/gba/core.cpp index dd1678d1..df3256ad 100644 --- a/src/nostalgia/core/gba/core.cpp +++ b/src/nostalgia/core/gba/core.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/gba/gfx.cpp b/src/nostalgia/core/gba/gfx.cpp index 60487fbb..cc50194d 100644 --- a/src/nostalgia/core/gba/gfx.cpp +++ b/src/nostalgia/core/gba/gfx.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include @@ -34,7 +30,6 @@ struct GbaPaletteTarget { struct GbaTileMapTarget { static constexpr auto TypeName = NostalgiaGraphic::TypeName; - static constexpr auto Fields = NostalgiaGraphic::Fields; static constexpr auto TypeVersion = NostalgiaGraphic::TypeVersion; volatile uint16_t *bgCtl = nullptr; ox::FileAddress defaultPalette; @@ -54,7 +49,7 @@ constexpr ox::Error modelRead(T *io, GbaPaletteTarget *t) noexcept { template constexpr ox::Error modelRead(T *io, GbaTileMapTarget *t) noexcept { - io->template setTypeInfo(GbaTileMapTarget::TypeName, GbaTileMapTarget::Fields); + io->template setTypeInfo(); uint8_t bpp; int dummy; oxReturnError(io->field("bpp", &bpp)); diff --git a/src/nostalgia/core/gba/gfx.hpp b/src/nostalgia/core/gba/gfx.hpp index 60169308..7f58e3b8 100644 --- a/src/nostalgia/core/gba/gfx.hpp +++ b/src/nostalgia/core/gba/gfx.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/gba/irq.arm.cpp b/src/nostalgia/core/gba/irq.arm.cpp index 54fb679b..0b217975 100644 --- a/src/nostalgia/core/gba/irq.arm.cpp +++ b/src/nostalgia/core/gba/irq.arm.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ // NOTE: this file is compiled as ARM and not THUMB, so don't but too much in diff --git a/src/nostalgia/core/gba/irq.hpp b/src/nostalgia/core/gba/irq.hpp index bb8cd68c..40f3b9eb 100644 --- a/src/nostalgia/core/gba/irq.hpp +++ b/src/nostalgia/core/gba/irq.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/gba/media.cpp b/src/nostalgia/core/gba/media.cpp index dbf89a6c..4851ac4d 100644 --- a/src/nostalgia/core/gba/media.cpp +++ b/src/nostalgia/core/gba/media.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/gba/panic.cpp b/src/nostalgia/core/gba/panic.cpp index ee3b1e03..89f540d1 100644 --- a/src/nostalgia/core/gba/panic.cpp +++ b/src/nostalgia/core/gba/panic.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/gba/tests.cpp b/src/nostalgia/core/gba/tests.cpp index 35789e55..5971aa49 100644 --- a/src/nostalgia/core/gba/tests.cpp +++ b/src/nostalgia/core/gba/tests.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/gfx.cpp b/src/nostalgia/core/gfx.cpp index f47d4062..eb5c087d 100644 --- a/src/nostalgia/core/gfx.cpp +++ b/src/nostalgia/core/gfx.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "gfx.hpp" diff --git a/src/nostalgia/core/gfx.hpp b/src/nostalgia/core/gfx.hpp index e8b47e67..d23b94c7 100644 --- a/src/nostalgia/core/gfx.hpp +++ b/src/nostalgia/core/gfx.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -25,14 +21,12 @@ enum class TileSheetSpace { struct NostalgiaPalette { static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.NostalgiaPalette"; - static constexpr auto Fields = 1; static constexpr auto TypeVersion = 1; ox::Vector colors; }; struct NostalgiaGraphic { static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.NostalgiaGraphic"; - static constexpr auto Fields = 6; static constexpr auto TypeVersion = 1; int8_t bpp = 0; // rows and columns are really only used by TileSheetEditor diff --git a/src/nostalgia/core/glfw/clipboard.cpp b/src/nostalgia/core/glfw/clipboard.cpp index 2374a0ed..8697334b 100644 --- a/src/nostalgia/core/glfw/clipboard.cpp +++ b/src/nostalgia/core/glfw/clipboard.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/glfw/core.cpp b/src/nostalgia/core/glfw/core.cpp index 8f22f655..8d73ced2 100644 --- a/src/nostalgia/core/glfw/core.cpp +++ b/src/nostalgia/core/glfw/core.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/glfw/core.hpp b/src/nostalgia/core/glfw/core.hpp index 602e57c4..029c926f 100644 --- a/src/nostalgia/core/glfw/core.hpp +++ b/src/nostalgia/core/glfw/core.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/glfw/gfx.cpp b/src/nostalgia/core/glfw/gfx.cpp index 9282995d..1d86a700 100644 --- a/src/nostalgia/core/glfw/gfx.cpp +++ b/src/nostalgia/core/glfw/gfx.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include @@ -49,7 +45,7 @@ ox::Error initGfx(Context *ctx) noexcept { ImGui::CreateContext(); auto &io = ImGui::GetIO(); io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; - io.MouseDrawCursor = true; + //io.MouseDrawCursor = true; ImGui_ImplGlfw_InitForOpenGL(id->window, true); } return renderer::init(ctx); diff --git a/src/nostalgia/core/input.hpp b/src/nostalgia/core/input.hpp index 42ab5462..1ff0b2c3 100644 --- a/src/nostalgia/core/input.hpp +++ b/src/nostalgia/core/input.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/media.cpp b/src/nostalgia/core/media.cpp index 49634ca5..e0732524 100644 --- a/src/nostalgia/core/media.cpp +++ b/src/nostalgia/core/media.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "media.hpp" diff --git a/src/nostalgia/core/media.hpp b/src/nostalgia/core/media.hpp index 054fab34..365d5758 100644 --- a/src/nostalgia/core/media.hpp +++ b/src/nostalgia/core/media.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/sdl/core.cpp b/src/nostalgia/core/sdl/core.cpp index 89f4e20b..b7ce2a6b 100644 --- a/src/nostalgia/core/sdl/core.cpp +++ b/src/nostalgia/core/sdl/core.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/sdl/core.hpp b/src/nostalgia/core/sdl/core.hpp index f6fa1369..24810702 100644 --- a/src/nostalgia/core/sdl/core.hpp +++ b/src/nostalgia/core/sdl/core.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/sdl/gfx.cpp b/src/nostalgia/core/sdl/gfx.cpp index 76b79942..dbbac8b6 100644 --- a/src/nostalgia/core/sdl/gfx.cpp +++ b/src/nostalgia/core/sdl/gfx.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/studio/CMakeLists.txt b/src/nostalgia/core/studio/CMakeLists.txt index eb4b2307..bf7ef63d 100644 --- a/src/nostalgia/core/studio/CMakeLists.txt +++ b/src/nostalgia/core/studio/CMakeLists.txt @@ -1,63 +1,27 @@ - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - add_library( NostalgiaCore-Studio OBJECT - imgconv.cpp - import_tilesheet_wizard.cpp + #imgconv.cpp + #import_tilesheet_wizard.cpp module.cpp - new_tilesheet_wizard.cpp - newpalettewizard.cpp - paletteeditor.cpp + #new_tilesheet_wizard.cpp + #newpalettewizard.cpp + #paletteeditor.cpp tilesheeteditor.cpp - util.cpp - rsrc.qrc + tilesheetpixelgrid.cpp + tilesheetpixels.cpp + #util.cpp + #rsrc.qrc ) if(NOT MSVC) target_compile_options(NostalgiaCore-Studio PRIVATE -Wsign-conversion) endif() -target_precompile_headers( - NostalgiaCore-Studio PRIVATE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -) - target_link_libraries( - NostalgiaCore-Studio - Qt${QT_VERSION_MAJOR}::QuickWidgets + NostalgiaCore-Studio PUBLIC NostalgiaStudio - NostalgiaCore-Qt - NostalgiaCore + NostalgiaCore-GLFW + NostalgiaGlUtils ) #target_compile_definitions(NostalgiaCore-Studio PRIVATE QT_QML_DEBUG) diff --git a/src/nostalgia/core/studio/Pixel.qml b/src/nostalgia/core/studio/Pixel.qml deleted file mode 100644 index f7a94332..00000000 --- a/src/nostalgia/core/studio/Pixel.qml +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2016 - 2020 gtalent2@gmail.com - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -import QtQuick 2.0 - -Rectangle { - id: pixel; - property int pixelNumber: index - color: sheetData ? sheetData.palette[pixelNumber < sheetData.pixels.length ? sheetData.pixels[pixelNumber] : 0] : 'black' - width: parent.width / 8 - height: parent.height / 8 - border.color: '#717d7e' - border.width: 1 - - Text { - text: (index % 8 + 1) + ', ' + Math.floor(index / 8 + 1) - font.family: 'Helvetica' - font.pointSize: 11 - color: '#717d7e88' - visible: pixel.width > 42 // that's acutally not HGtG reference - anchors.horizontalCenter: pixel.horizontalCenter - anchors.bottom: pixel.bottom - } - - Rectangle { - visible: sheetData ? sheetData.pixelSelected[pixel.pixelNumber] & 1 == 1 : false - color: '#0088ff' - opacity: 0.5 - width: parent.width - height: parent.height - } - -} diff --git a/src/nostalgia/core/studio/Tile.qml b/src/nostalgia/core/studio/Tile.qml deleted file mode 100644 index 14ccb97f..00000000 --- a/src/nostalgia/core/studio/Tile.qml +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2016 - 2019 gtalent2@gmail.com - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -import QtQuick 2.0 - -Rectangle { - id: tile; - property int tileNumber: -1 - width: parent.width - height: parent.height - x: parent.width / 2 - tile.width / 2 - y: parent.height / 2 - tile.height / 2 - color: '#000000' - - function pixelAt(x, y) { - return tileGrid.childAt(x, y); - } - - Grid { - id: tileGrid - width: tile.width - height: tile.height - rows: 8 - columns: 8 - Repeater { - model: 64 - Pixel { - pixelNumber: index + 64 * tile.tileNumber - } - } - } - - // place an outline Rectangle above the pixels - Rectangle { - width: parent.width - height: parent.height - // make fill transparent - color: '#00000000' - border.color: '#000000' - border.width: 2 - } - -} diff --git a/src/nostalgia/core/studio/TileSheetEditor.qml b/src/nostalgia/core/studio/TileSheetEditor.qml deleted file mode 100644 index fd43a090..00000000 --- a/src/nostalgia/core/studio/TileSheetEditor.qml +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2016 - 2020 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -import QtQuick 2.0 -import QtQuick.Controls 2.14 -import 'qrc:/qml/' - -Rectangle { - id: tileSheetEditor - clip: true - color: '#717d7e' - - MouseArea { - id: mouseArea - width: tileSheetEditor.width - height: tileSheetEditor.height - acceptedButtons: Qt.LeftButton | Qt.RightButton - - onClicked: { - if (mouse.button === Qt.RightButton) { - var tile = mouseArea.tileAt(mouseX, mouseY); - if (tile) { - contextMenu.popup(); - } - } else { - contextMenu.dismiss(); - switch (sheetData.activeTool) { - case 'Fill': - { - var pixel = pixelAt(mouseX, mouseY); - if (pixel) { - sheetData.fillPixel(pixel); - } - break; - } - } - } - } - - onPressed: { - if (mouse.button === Qt.LeftButton && !contextMenu.visible) { - switch (sheetData.activeTool) { - case 'Draw': - var pixel = pixelAt(mouseX, mouseY); - if (pixel) { - sheetData.beginCmd(); - sheetData.updatePixel(pixel); - } - break; - case 'Select': - var pixel = pixelAt(mouseX, mouseY); - if (pixel) { - sheetData.beginCmd(); - sheetData.selectPixel(pixel); - } - break; - } - } - } - - onWheel: { - if (wheel.modifiers & Qt.ControlModifier) { - const mod = tileGrid.scaleFactor / 10; - if (wheel.angleDelta.y > 0 && tileGrid.scaleFactor < 7) { - tileGrid.scaleFactor += mod; - } else if (tileGrid.scaleFactor > 0.9) { - tileGrid.scaleFactor -= mod; - } - - - if (tileGrid.width <= this.width) { - tileGrid.x = this.width / 2 - tileGrid.width / 2; - } - if (tileGrid.height <= this.height) { - tileGrid.y = this.height / 2 - tileGrid.height / 2; - } - } else { - const mod = 15; - if (tileGrid.width > this.width) { - if (wheel.angleDelta.x > 0) { - if (tileGrid.x < tileGrid.width / 2) { - tileGrid.x += mod; - } - } else if (wheel.angleDelta.x < 0) { - let x2 = tileGrid.x + tileGrid.width; - if (x2 > this.width / 2) { - tileGrid.x -= mod; - } - } - } - if (tileGrid.height > this.height) { - if (wheel.angleDelta.y > 0) { - if (tileGrid.y < this.height / 2) { - tileGrid.y += mod; - } - } else if (wheel.angleDelta.y < 0) { - let y2 = tileGrid.y + tileGrid.height; - if (y2 > this.height / 2) { - tileGrid.y -= mod; - } - } - } - } - wheel.accepted = true; - } - - Menu { - id: contextMenu - - MenuItem { - text: "Insert Tile" - onTriggered: { - var tile = mouseArea.tileAt(contextMenu.x, contextMenu.y); - if (tile) { - sheetData.insertTileCmd(tile.tileNumber); - } - } - } - - MenuItem { - text: "Delete Tile" - onTriggered: { - var tile = mouseArea.tileAt(contextMenu.x, contextMenu.y); - sheetData.deleteTileCmd(tile.tileNumber); - } - } - } - - onPositionChanged: { - if (mouseArea.pressedButtons & Qt.LeftButton && !contextMenu.visible) { - var pixel = pixelAt(mouseX, mouseY); - switch (sheetData.activeTool) { - case 'Draw': - if (pixel) { - sheetData.updatePixel(pixel); - } - break; - case 'Select': - if (pixel) { - sheetData.selectPixel(pixel); - } - break; - } - } - } - - onReleased: sheetData.endCmd() - onCanceled: sheetData.endCmd() - - function tileAt(x, y) { - var gridX = x - tileGrid.x; - var gridY = y - tileGrid.y; - return tileGrid.childAt(gridX, gridY); - } - - function pixelAt(x, y) { - var gridX = x - tileGrid.x; - var gridY = y - tileGrid.y; - var tile = tileGrid.childAt(gridX, gridY); - if (tile === null) { - return null; - } - var tileX = gridX - tile.x; - var tileY = gridY - tile.y; - var pixel = tile.pixelAt(tileX, tileY); - return pixel; - } - - } - - Grid { - id: tileGrid - property double scaleFactor: 0.9 - property int baseTileSize: Math.min(2000 / tileGrid.columns, 1000 / tileGrid.rows) - x: tileSheetEditor.width / 2 - this.width / 2 - y: tileSheetEditor.height / 2 - this.height / 2 - width: tileGrid.columns * tileGrid.baseTileSize * tileGrid.scaleFactor - height: tileGrid.rows * tileGrid.baseTileSize * tileGrid.scaleFactor - rows: sheetData ? sheetData.rows : 1 - columns: sheetData ? sheetData.columns : 1 - states: State { - name: "widthChanged" - PropertyChanges { target: tileGrid.width; width: tileGrid.columns * tileGrid.baseTileSize * tileGrid.scaleFactor } - } - Repeater { - model: tileGrid.rows * tileGrid.columns - Tile { - tileNumber: index - width: tileGrid.width / tileGrid.columns - height: tileGrid.height / tileGrid.rows - } - } - } - -} diff --git a/src/nostalgia/core/studio/consts.hpp b/src/nostalgia/core/studio/consts.hpp index 67c7d9c2..8acb7909 100644 --- a/src/nostalgia/core/studio/consts.hpp +++ b/src/nostalgia/core/studio/consts.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/studio/imgconv.cpp b/src/nostalgia/core/studio/imgconv.cpp index 96f31915..46158d62 100644 --- a/src/nostalgia/core/studio/imgconv.cpp +++ b/src/nostalgia/core/studio/imgconv.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include @@ -16,9 +12,8 @@ namespace nostalgia::core { -namespace { - -[[nodiscard]] uint16_t toGbaColor(QColor c) { +[[nodiscard]] +static uint16_t toGbaColor(QColor c) { const auto r = static_cast(c.red()) >> 3; const auto g = static_cast(c.green()) >> 3; const auto b = static_cast(c.blue()) >> 3; @@ -26,9 +21,8 @@ namespace { return (a << 15) | (r << 10) | (g << 5) | (b << 0); } -} - -[[nodiscard]] static int countColors(const QImage &img, int argTiles) { +[[nodiscard]] +static int countColors(const QImage &img, int argTiles) { QMap colors; // copy pixels as color ids for (int x = 0; x < img.width(); x++) { @@ -46,7 +40,8 @@ namespace { return colors.size(); } -[[nodiscard]] std::unique_ptr imgToNg(QString argSrc, int argBpp) { +[[nodiscard]] +ox::UniquePtr imgToNg(QString argSrc, int argBpp) { QImage src(argSrc); if (src.isNull()) { diff --git a/src/nostalgia/core/studio/imgconv.hpp b/src/nostalgia/core/studio/imgconv.hpp index 1d3861aa..01506eeb 100644 --- a/src/nostalgia/core/studio/imgconv.hpp +++ b/src/nostalgia/core/studio/imgconv.hpp @@ -1,15 +1,9 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once -#include - #include #include @@ -19,16 +13,7 @@ namespace nostalgia::core { -[[nodiscard]] constexpr int pointToIdx(int w, int x, int y) noexcept { - constexpr auto colLength = PixelsPerTile; - const auto rowLength = (w / TileWidth) * colLength; - const auto colStart = colLength * (x / TileWidth); - const auto rowStart = rowLength * (y / TileHeight); - const auto colOffset = x % TileWidth; - const auto rowOffset = (y % TileHeight) * TileHeight; - return colStart + colOffset + rowStart + rowOffset; -} - -[[nodiscard]] std::unique_ptr imgToNg(QString argInPath, int argBpp = -1); +[[nodiscard]] +ox::UniquePtr imgToNg(ox::String argInPath, int argBpp = -1); } diff --git a/src/nostalgia/core/studio/import_tilesheet_wizard.cpp b/src/nostalgia/core/studio/import_tilesheet_wizard.cpp index fe10d9b8..b1154dbb 100644 --- a/src/nostalgia/core/studio/import_tilesheet_wizard.cpp +++ b/src/nostalgia/core/studio/import_tilesheet_wizard.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/studio/import_tilesheet_wizard.hpp b/src/nostalgia/core/studio/import_tilesheet_wizard.hpp index 35417d19..5f7fa708 100644 --- a/src/nostalgia/core/studio/import_tilesheet_wizard.hpp +++ b/src/nostalgia/core/studio/import_tilesheet_wizard.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/studio/module.cpp b/src/nostalgia/core/studio/module.cpp index 4ffbd297..e7db2987 100644 --- a/src/nostalgia/core/studio/module.cpp +++ b/src/nostalgia/core/studio/module.cpp @@ -1,71 +1,22 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ -#include "new_tilesheet_wizard.hpp" -#include "newpalettewizard.hpp" -#include "import_tilesheet_wizard.hpp" -#include "paletteeditor.hpp" #include "tilesheeteditor.hpp" #include "module.hpp" namespace nostalgia::core { -QVector Module::newWizards(const studio::Context *ctx) { - return { - { - tr("Palette"), - [ctx]() { - QVector pgs; - pgs.push_back(new NewPaletteWizardPage(ctx)); - return pgs; - } - }, - { - tr("Tile Sheet"), - [ctx]() { - QVector pgs; - pgs.push_back(new NewTilesheetWizardPage(ctx)); - return pgs; - } - }, - }; -} - -QVector Module::importWizards(const studio::Context *ctx) { - return { - { - tr("Tile Sheet"), - [ctx]() { - QVector pgs; - pgs.push_back(new ImportTilesheetWizardMainPage(ctx)); - pgs.push_back(new ImportTilesheetWizardPalettePage(ctx)); - return pgs; - } - } - }; -} - -QVector Module::editors(const studio::Context *ctx) { +ox::Vector Module::editors(core::Context *ctx) { return { { {"ng"}, - [ctx](QString path) { - return new TileSheetEditor(path, ctx, ctx->tabParent); - } - }, - { - {"npal"}, - [ctx](QString path) { - return new PaletteEditor(path, ctx, ctx->tabParent); + [ctx](const ox::String &path) { + return new TileSheetEditor(ctx, path); } } }; } -} +} \ No newline at end of file diff --git a/src/nostalgia/core/studio/module.hpp b/src/nostalgia/core/studio/module.hpp index c94d5bae..f12ea410 100644 --- a/src/nostalgia/core/studio/module.hpp +++ b/src/nostalgia/core/studio/module.hpp @@ -1,31 +1,16 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once -#include - #include namespace nostalgia::core { -class Module: public QObject, public studio::Module { - Q_OBJECT - Q_PLUGIN_METADATA(IID "net.drinkingtea.nostalgia.core.studio.Module" FILE "core-studio.json") - Q_INTERFACES(nostalgia::studio::Module) - +class Module: public studio::Module { public: - QVector newWizards(const studio::Context *ctx) override; - - QVector importWizards(const studio::Context *args) override; - - QVector editors(const studio::Context *ctx) override; - + ox::Vector editors(core::Context *ctx) override; }; } diff --git a/src/nostalgia/core/studio/new_tilesheet_wizard.cpp b/src/nostalgia/core/studio/new_tilesheet_wizard.cpp index e414bbdc..575023fc 100644 --- a/src/nostalgia/core/studio/new_tilesheet_wizard.cpp +++ b/src/nostalgia/core/studio/new_tilesheet_wizard.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/studio/new_tilesheet_wizard.hpp b/src/nostalgia/core/studio/new_tilesheet_wizard.hpp index 9072fe5b..a0d12224 100644 --- a/src/nostalgia/core/studio/new_tilesheet_wizard.hpp +++ b/src/nostalgia/core/studio/new_tilesheet_wizard.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/studio/newpalettewizard.cpp b/src/nostalgia/core/studio/newpalettewizard.cpp index 55dad2ff..898822e2 100644 --- a/src/nostalgia/core/studio/newpalettewizard.cpp +++ b/src/nostalgia/core/studio/newpalettewizard.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/studio/newpalettewizard.hpp b/src/nostalgia/core/studio/newpalettewizard.hpp index 4f2dffa9..43764d93 100644 --- a/src/nostalgia/core/studio/newpalettewizard.hpp +++ b/src/nostalgia/core/studio/newpalettewizard.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/studio/paletteeditor.cpp b/src/nostalgia/core/studio/paletteeditor.cpp index 4d1cd9ed..23e55407 100644 --- a/src/nostalgia/core/studio/paletteeditor.cpp +++ b/src/nostalgia/core/studio/paletteeditor.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/studio/paletteeditor.hpp b/src/nostalgia/core/studio/paletteeditor.hpp index 8bffd93e..7dbf2346 100644 --- a/src/nostalgia/core/studio/paletteeditor.hpp +++ b/src/nostalgia/core/studio/paletteeditor.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/studio/ptidxconv.hpp b/src/nostalgia/core/studio/ptidxconv.hpp new file mode 100644 index 00000000..1b4dca8f --- /dev/null +++ b/src/nostalgia/core/studio/ptidxconv.hpp @@ -0,0 +1,55 @@ +/* + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#pragma once + +#include + +namespace nostalgia::core { + +[[nodiscard]] +constexpr int pointToIdx(int w, int x, int y) noexcept { + constexpr auto colLength = PixelsPerTile; + const auto rowLength = (w / TileWidth) * colLength; + const auto colStart = colLength * (x / TileWidth); + const auto rowStart = rowLength * (y / TileHeight); + const auto colOffset = x % TileWidth; + const auto rowOffset = (y % TileHeight) * TileHeight; + return colStart + colOffset + rowStart + rowOffset; +} + +[[nodiscard]] +constexpr int ptToIdx(int x, int y, int c) noexcept { + return pointToIdx(c * TileWidth, x, y); +} + +[[nodiscard]] +constexpr int ptToIdx(common::Point pt, int c) noexcept { + return pointToIdx(c * TileWidth, pt.x, pt.y); +} + +[[nodiscard]] +constexpr common::Point idxToPt(int i, int c) noexcept { + const auto t = i / PixelsPerTile; // tile number + const auto iti = i % PixelsPerTile; // in tile index + const auto tc = t % c; // tile column + const auto tr = t / c; // tile row + const auto itx = iti % TileWidth; // in tile x + const auto ity = iti / TileHeight; // in tile y + return { + itx + tc * TileWidth, + ity + tr * TileHeight, + }; +} + +static_assert(idxToPt(4, 1) == common::Point{4, 0}); +static_assert(idxToPt(8, 1) == common::Point{0, 1}); +static_assert(idxToPt(8, 2) == common::Point{0, 1}); +static_assert(idxToPt(64, 2) == common::Point{8, 0}); +static_assert(idxToPt(128, 2) == common::Point{0, 8}); +static_assert(idxToPt(129, 2) == common::Point{1, 8}); +static_assert(idxToPt(192, 2) == common::Point{8, 8}); +static_assert(idxToPt(384, 8) == common::Point{48, 0}); + +} diff --git a/src/nostalgia/core/studio/rsrc.qrc b/src/nostalgia/core/studio/rsrc.qrc deleted file mode 100644 index f8e0dd71..00000000 --- a/src/nostalgia/core/studio/rsrc.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - Pixel.qml - Tile.qml - TileSheetEditor.qml - - diff --git a/src/nostalgia/core/studio/tilesheeteditor.cpp b/src/nostalgia/core/studio/tilesheeteditor.cpp index 768fc204..1759115d 100644 --- a/src/nostalgia/core/studio/tilesheeteditor.cpp +++ b/src/nostalgia/core/studio/tilesheeteditor.cpp @@ -1,1060 +1,76 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include #include +#include -#include "consts.hpp" -#include "imgconv.hpp" -#include "util.hpp" #include "tilesheeteditor.hpp" namespace nostalgia::core { -[[nodiscard]] constexpr int ptToIdx(int x, int y, int c) noexcept { - return pointToIdx(c * TileWidth, x, y); -} - -[[nodiscard]] constexpr int ptToIdx(common::Point pt, int c) noexcept { - return pointToIdx(c * TileWidth, pt.x, pt.y); -} - -[[nodiscard]] constexpr common::Point idxToPt(int i, int c) noexcept { - const auto t = i / PixelsPerTile; // tile number - const auto iti = i % PixelsPerTile; // in tile index - const auto tc = t % c; // tile column - const auto tr = t / c; // tile row - const auto itx = iti % TileWidth; // in tile x - const auto ity = iti / TileHeight; // in tile y - return { - itx + tc * TileWidth, - ity + tr * TileHeight, - }; -} - -static_assert(idxToPt(4, 1) == common::Point{4, 0}); -static_assert(idxToPt(8, 1) == common::Point{0, 1}); -static_assert(idxToPt(8, 2) == common::Point{0, 1}); -static_assert(idxToPt(64, 2) == common::Point{8, 0}); -static_assert(idxToPt(128, 2) == common::Point{0, 8}); -static_assert(idxToPt(129, 2) == common::Point{1, 8}); -static_assert(idxToPt(192, 2) == common::Point{8, 8}); -static_assert(idxToPt(384, 8) == common::Point{48, 0}); - -class ModAfterDialog: public QDialog { - - private: - QComboBox *const m_afterColor = new QComboBox(this); - QSpinBox *const m_mod = new QSpinBox(this); - - public: - ModAfterDialog(const QStringList &palette, QWidget *parent = nullptr): QDialog(parent) { - auto range = palette.size(); - auto okBtn = new QPushButton(tr("&OK"), this); - setWindowTitle(tr("Mod Colors After")); - setWindowModality(Qt::WindowModality::ApplicationModal); - for (int i = 0; i < palette.size(); ++i) { - const auto c = palette[i]; - m_afterColor->addItem(QString("%1: %2").arg(i + 1).arg(c)); - } - m_mod->setMinimum(-range + 1); - m_mod->setMaximum(range - 1); - auto lyt = new QFormLayout(this); - lyt->addRow(tr("&Greater/Equal To:"), m_afterColor); - lyt->addRow(tr("&Mod By:"), m_mod); - lyt->addWidget(okBtn); - connect(okBtn, &QPushButton::clicked, this, &ModAfterDialog::accept); - } - - int color() const { - return m_afterColor->currentIndex() - 1; - } - - int mod() const { - return m_mod->value(); - } - -}; - -struct LabeledSpinner: public QWidget { - - QSpinBox *const spinBox = new QSpinBox(this); - - LabeledSpinner(QString name, int minimum, int value) { - auto lyt = new QHBoxLayout; - setLayout(lyt); - auto lbl = new QLabel(name, this); - lbl->setBuddy(spinBox); - lyt->addWidget(lbl); - lyt->addWidget(spinBox); - spinBox->setMinimum(minimum); - spinBox->setValue(value); - } - - virtual ~LabeledSpinner() = default; - -}; - -class UpdateDimensionsCommand: public QUndoCommand { - public: - enum class Dimension { - Rows, - Columns, - }; - - private: - Dimension m_dimension = Dimension::Rows; - int m_oldVal = 0; - int m_newVal = 0; - SheetData *m_sheetData = nullptr; - - public: - UpdateDimensionsCommand(SheetData *sheetData, Dimension dim, int oldVal, int newVal) { - m_sheetData = sheetData; - m_dimension = dim; - m_newVal = newVal; - m_oldVal = oldVal; - setObsolete(newVal == oldVal); - } - - virtual ~UpdateDimensionsCommand() = default; - - int id() const override { - return static_cast(CommandId::UpdateDimension); - } - - void redo() override { - switch (m_dimension) { - case Dimension::Rows: - m_sheetData->setRows(m_newVal); - break; - case Dimension::Columns: - m_sheetData->setColumns(m_newVal); - break; - } - } - - void undo() override { - switch (m_dimension) { - case Dimension::Rows: - m_sheetData->setRows(m_oldVal); - break; - case Dimension::Columns: - m_sheetData->setColumns(m_oldVal); - break; - } - } - -}; - - -class ModPixelsCommand: public QUndoCommand { - private: - SheetData *m_sheetData = nullptr; - QHash m_pixelUpdates; - - public: - ModPixelsCommand(SheetData *sheetData): m_sheetData(sheetData) { - } - - virtual ~ModPixelsCommand() = default; - - void addPixel(int index, int mod) { - m_pixelUpdates[index] = mod; - } - - int id() const override { - return static_cast(CommandId::ModPixel); - } - - void redo() override { - m_sheetData->modPixels(m_pixelUpdates, 1); - } - - void undo() override { - m_sheetData->modPixels(m_pixelUpdates, -1); - } - -}; - -class FillPixelsCommand: public QUndoCommand { - private: - const std::array m_pixelUpdateMap; - const std::size_t m_idx = 0; - const int m_oldColor = 0; - const int m_newColor = 0; - SheetData *const m_sheetData = nullptr; - - public: - FillPixelsCommand(SheetData *sheetData, const std::array &pum, int idx, int oldColor, int newColor): - m_pixelUpdateMap(pum), - m_idx(static_cast(idx)), - m_oldColor(oldColor), - m_newColor(newColor), - m_sheetData(sheetData) { - } - - virtual ~FillPixelsCommand() = default; - - int id() const override { - return static_cast(CommandId::ModPixel); - } - - void redo() override { - for (std::size_t i = 0; i < m_pixelUpdateMap.size(); ++i) { - if (m_pixelUpdateMap[i]) { - m_sheetData->setPixel(i + m_idx, m_newColor); - } - } - m_sheetData->notifyUpdate(); - } - - void undo() override { - for (std::size_t i = 0; i < m_pixelUpdateMap.size(); ++i) { - if (m_pixelUpdateMap[i]) { - m_sheetData->setPixel(i + m_idx, m_oldColor); - } - } - m_sheetData->notifyUpdate(); - } - -}; - -class UpdatePixelsCommand: public QUndoCommand { - private: - struct PixelUpdate { - QPointer item; - int oldColorId = 0; - - bool operator==(const PixelUpdate &o) const { - return item == o.item; - } - - bool operator<(const PixelUpdate &o) const { - return item < o.item; - } - - operator quint64() const { - return reinterpret_cast(item.data()); - } - }; - - uint64_t m_cmdIdx = 0; - int m_newColorId = 0; - const QStringList &m_palette; - QVector &m_pixels; - QVector &m_pixelSelected; - QSet m_pixelUpdates; - - public: - UpdatePixelsCommand(QVector &pixels, QVector &pixelSelected, const QStringList &palette, QQuickItem *pixelItem, int newColorId, uint64_t cmdIdx): m_palette(palette), m_pixels(pixels), m_pixelSelected(pixelSelected) { - m_newColorId = newColorId; - m_cmdIdx = cmdIdx; - PixelUpdate pu; - pu.item = pixelItem; - pu.oldColorId = m_palette.indexOf(pixelItem->property("color").value().name(QColor::HexRgb)); - m_pixelUpdates.insert(pu); - setObsolete(pu.oldColorId == newColorId); - } - - virtual ~UpdatePixelsCommand() = default; - - int id() const override { - return static_cast(CommandId::UpdatePixel); - } - - bool mergeWith(const QUndoCommand *cmd) override { - auto other = dynamic_cast(cmd); - if (other && m_cmdIdx == other->m_cmdIdx) { - m_pixelUpdates.unite(other->m_pixelUpdates); - return true; - } - return false; - } - - void redo() override { - for (const auto &pu : m_pixelUpdates) { - pu.item->setProperty("color", m_palette[m_newColorId]); - const auto index = pu.item->property("pixelNumber").toInt(); - // resize to appropriate number of tiles if pixel beyond current - // range - if (m_pixels.size() < index) { - auto sz = (index / 64 + 1) * 64; - m_pixels.resize(sz); - m_pixelSelected.resize(sz); - } - m_pixels[index] = m_newColorId; - } - } - - void undo() override { - for (const auto &pu : m_pixelUpdates) { - pu.item->setProperty("color", m_palette[pu.oldColorId]); - m_pixels[pu.item->property("pixelNumber").toInt()] = pu.oldColorId; - } - } - -}; - - -class InsertTileCommand: public QUndoCommand { - private: - SheetData *m_sheetData = nullptr; - int m_idx = 0; - bool m_delete = false; - QVector m_tileRestore; - - public: - InsertTileCommand(SheetData *sheetData, int idx, bool del = false) { - m_sheetData = sheetData; - m_idx = idx; - m_delete = del; - } - - virtual ~InsertTileCommand() = default; - - int id() const override { - return static_cast(CommandId::InsertTile); - } - - void redo() override { - if (m_delete) { - m_tileRestore = m_sheetData->deleteTile(m_idx); - } else { - m_sheetData->insertTile(m_idx, m_tileRestore); - } - } - - void undo() override { - if (m_delete) { - m_sheetData->insertTile(m_idx, m_tileRestore); - } else { - m_tileRestore = m_sheetData->deleteTile(m_idx); - } - } - -}; - -class PasteClipboardCommand: public QUndoCommand { - private: - SheetData *m_sheetData = nullptr; - std::unique_ptr m_restore; - std::unique_ptr m_apply; - - public: - PasteClipboardCommand(SheetData *sheetData, - std::unique_ptr &&restore, - std::unique_ptr &&apply): m_sheetData(sheetData), m_restore(std::move(restore)), m_apply(std::move(apply)) { - } - - virtual ~PasteClipboardCommand() = default; - - int id() const override { - return static_cast(CommandId::ClipboardPaste); - } - - void redo() override { - m_sheetData->applyClipboard(*m_apply); - } - - void undo() override { - m_sheetData->applyClipboard(*m_restore); - } - -}; - - -void TileSheetClipboard::addPixel(int color) { - m_pixels.push_back(color); -} - -bool TileSheetClipboard::empty() const { - return m_pixels.empty(); -} - -void TileSheetClipboard::pastePixels(common::Point pt, QVector *tgtPixels, int tgtColumns) const { - std::size_t srcIdx = 0; - const auto w = m_p2.x - m_p1.x; - const auto h = m_p2.y - m_p1.y; - for (int x = 0; x <= w; ++x) { - for (int y = 0; y <= h; ++y) { - const auto tgtIdx = ptToIdx(pt + common::Point(x, y), tgtColumns); - if (tgtIdx < tgtPixels->size()) { - (*tgtPixels)[tgtIdx] = m_pixels[srcIdx]; - } - ++srcIdx; - } - } -} - -void TileSheetClipboard::setPoints(common::Point p1, common::Point p2) { - m_p1 = p1; - m_p2 = p2; -} - -common::Point TileSheetClipboard::point1() const { - return m_p1; -} - -common::Point TileSheetClipboard::point2() const { - return m_p2; -} - - -void TileSheetEditorColorTableDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &idx) const { - if (idx.column() != 1) { - QStyledItemDelegate::paint(painter, opt, idx); - } else { - auto color = idx.model()->data(idx, Qt::DisplayRole).toString(); - painter->fillRect(opt.rect, QColor(color)); - } -} - - -SheetData::SheetData(QUndoStack *undoStack): m_cmdStack(undoStack) { -} - -void SheetData::fillPixel(QVariant pixelItem) { - const auto p = qobject_cast(pixelItem.value()); - if (p && p != m_prevPixelOperand) { - const auto idx = p->property("pixelNumber").toInt(); - const auto pt = idxToPt(idx, m_columns); - const auto oldColor = m_pixels[idx]; - std::array pixels = {}; - getFillPixels(pixels.data(), pt, oldColor); - m_cmdStack->push(new FillPixelsCommand(this, pixels, idx / PixelsPerTile * PixelsPerTile, oldColor, m_selectedColor)); - } -} - -void SheetData::selectPixel(QVariant pixelItem) { - auto p = qobject_cast(pixelItem.value()); - if (p && p != m_prevPixelOperand) { - const auto index = p->property("pixelNumber").toInt(); - const auto point = idxToPt(index, m_columns); - m_prevPixelOperand = p; - if (m_selectionStart == common::Point{-1, -1}) { - m_selectionStart = point; - } - markSelection(point); - } -} - -void SheetData::updatePixel(QVariant pixelItem) { - auto p = qobject_cast(pixelItem.value()); - if (p && p != m_prevPixelOperand) { - m_cmdStack->push(new UpdatePixelsCommand(m_pixels, m_pixelSelected, m_palette, p, m_selectedColor, m_cmdIdx)); - m_prevPixelOperand = p; - emit changeOccurred(); - } -} - -void SheetData::beginCmd() { - ++m_cmdIdx; - m_selectionStart = {-1, -1}; - m_selectionEnd = {-1, -1}; - emit pixelSelectedChanged(0); -} - -void SheetData::endCmd() { - m_prevPixelOperand = nullptr; -} - -void SheetData::insertTileCmd(int tileIdx) { - m_cmdStack->push(new InsertTileCommand(this, tileIdx)); -} - -void SheetData::deleteTileCmd(int tileIdx) { - m_cmdStack->push(new InsertTileCommand(this, tileIdx, true)); -} - -int SheetData::columns() const { - return m_columns; -} - -int SheetData::rows() const { - return m_rows; -} - -const QVector &SheetData::pixelSelected() const { - return m_pixelSelected; -} - -const QVector &SheetData::pixels() const { - return m_pixels; -} - -QStringList SheetData::palette() const { - return m_palette; -} - -QString SheetData::palettePath() const { - return m_currentPalettePath; -} - -void SheetData::getFillPixels(bool *pixels, common::Point pt, int oldColor) const { - const auto tileIdx = [this](const common::Point &pt) noexcept { - return ptToIdx(pt, m_columns) / PixelsPerTile; - }; - // get points - const auto leftPt = pt + common::Point(-1, 0); - const auto rightPt = pt + common::Point(1, 0); - const auto topPt = pt + common::Point(0, -1); - const auto bottomPt = pt + common::Point(0, 1); - // calculate indices - const auto idx = ptToIdx(pt, m_columns); - const auto leftIdx = ptToIdx(leftPt, m_columns); - const auto rightIdx = ptToIdx(rightPt, m_columns); - const auto topIdx = ptToIdx(topPt, m_columns); - const auto bottomIdx = ptToIdx(bottomPt, m_columns); - const auto tile = tileIdx(pt); - // mark pixels to update - pixels[idx % PixelsPerTile] = true; - if (!pixels[leftIdx % PixelsPerTile] && tile == tileIdx(leftPt) && m_pixels[leftIdx] == oldColor) { - getFillPixels(pixels, leftPt, oldColor); - } - if (!pixels[rightIdx % PixelsPerTile] && tile == tileIdx(rightPt) && m_pixels[rightIdx] == oldColor) { - getFillPixels(pixels, rightPt, oldColor); - } - if (!pixels[topIdx % PixelsPerTile] && tile == tileIdx(topPt) && m_pixels[topIdx] == oldColor) { - getFillPixels(pixels, topPt, oldColor); - } - if (!pixels[bottomIdx % PixelsPerTile] && tile == tileIdx(bottomPt) && m_pixels[bottomIdx] == oldColor) { - getFillPixels(pixels, bottomPt, oldColor); - } -} - -void SheetData::load(const studio::Context *ctx, QString ngPath, QString palPath) { - auto ng = ctx->project->loadObj(ngPath); - if (palPath == "" && ng->defaultPalette.type() == ox::FileAddressType::Path) { - palPath = ng->defaultPalette.getPath().value; - } - m_tilesheetPath = ngPath; - m_currentPalettePath = palPath; - setRows(ng->rows); - setColumns(ng->columns); - if (palPath != "") { - setPalette(ctx, palPath); - } else { - setPalette(&ng->pal); - } - updatePixels(ng.get()); -} - -void SheetData::reload(const studio::Context *ctx) { - load(ctx, m_tilesheetPath, m_currentPalettePath); -} - -void SheetData::save(const studio::Context *ctx, QString ngPath) const { - auto ng = toNostalgiaGraphic(); - ctx->project->writeObj(ngPath, ng.get()); -} - -void SheetData::setPalette(const NostalgiaPalette *npal) { - // load palette - m_palette.clear(); - for (const auto &c : npal->colors) { - const auto qc = toQColor(c); - const auto color = qc.name(QColor::HexRgb); - m_palette.append(color); - } - emit paletteChanged(); -} - -void SheetData::setPalette(const studio::Context *ctx, QString palPath) { - std::unique_ptr npal; - try { - npal = ctx->project->loadObj(palPath); - } catch (ox::Exception&) { - qWarning() << "Could not open palette" << palPath; - } - if (npal) { - setPalette(npal.get()); - } - m_currentPalettePath = palPath; - emit changeOccurred(); -} - -void SheetData::insertTile(int tileIdx, QVector tileData) { - auto pxIdx = tileIdx * PixelsPerTile; - m_pixels.insert(pxIdx, PixelsPerTile, 0); - m_pixelSelected.insert(pxIdx, PixelsPerTile, 0); - std::copy(tileData.begin(), tileData.end(), &m_pixels[pxIdx]); - notifyUpdate(); -} - -QVector SheetData::deleteTile(int tileIdx) { - QVector out; - auto pxIdx = tileIdx * PixelsPerTile; - std::copy(m_pixels.begin() + pxIdx, - m_pixels.begin() + (pxIdx + PixelsPerTile), - std::back_inserter(out)); - m_pixels.remove(pxIdx, PixelsPerTile); - m_pixelSelected.remove(pxIdx, PixelsPerTile); - notifyUpdate(); - return out; -} - -void SheetData::setSelectedColor(int index) { - m_selectedColor = index; -} - -void SheetData::modGteCmd(int color, int mod) { - auto cmd = new ModPixelsCommand(this); - for (int i = 0; i < m_pixels.size(); ++i) { - const auto p = m_pixels[i]; - if (p >= color) { - const int mx = (m_palette.size() - p) - 1; - cmd->addPixel(i, std::clamp(mod, -p, mx)); - } - } - m_cmdStack->push(cmd); -} - -void SheetData::modPixels(const QHash &mods, int inversion) { - for (const auto index : mods.keys()) { - const auto mod = mods[index]; - m_pixels[index] += mod * inversion; - } - notifyUpdate(); -} - -void SheetData::setPixel(int index, int color) { - m_pixels[index] = color; -} - -void SheetData::notifyUpdate() { - emit pixelsChanged(); - emit changeOccurred(); -} - -std::unique_ptr SheetData::toNostalgiaGraphic() const { - auto ng = std::make_unique(); - const auto highestColorIdx = static_cast(*std::max_element(m_pixels.begin(), m_pixels.end())); - ng->defaultPalette = m_currentPalettePath.toUtf8().data(); - ng->bpp = highestColorIdx > 15 ? 8 : 4; - ng->columns = m_columns; - ng->rows = m_rows; - auto pixelCount = static_cast(ng->rows * ng->columns * PixelsPerTile); - if (ng->bpp == 4) { - ng->pixels.resize(pixelCount / 2); - for (std::size_t i = 0; i < pixelCount && i < static_cast(m_pixels.size()); ++i) { - if (i & 1) { - ng->pixels[i / 2] |= static_cast(m_pixels[static_cast(i)]) << 4; - } else { - ng->pixels[i / 2] = static_cast(m_pixels[static_cast(i)]); - } - } - } else { - ng->pixels.resize(pixelCount); - for (std::size_t i = 0; i < ng->pixels.size(); ++i) { - ng->pixels[i] = static_cast(m_pixels[static_cast(i)]); - } - } - return ng; -} - -int SheetData::activeTool() const { - return static_cast(m_activeTool); -} - -bool SheetData::clipboardEmpty() const { - return m_clipboard.empty(); -} - -void SheetData::cutToClipboard() { - m_clipboard.setPoints(m_selectionStart, m_selectionEnd); - cutToClipboard(&m_clipboard); -} - -void SheetData::cutToClipboard(TileSheetClipboard *cb) { - const auto pt1 = cb->point1(); - const auto pt2 = cb->point2(); - auto apply = std::make_unique(); - for (int x = pt1.x; x <= pt2.x; ++x) { - for (int y = pt1.y; y <= pt2.y; ++y) { - const auto pt = common::Point(x, y); - const auto i = ptToIdx(pt, m_columns); - const auto s = m_pixelSelected[i]; - if (s) { - cb->addPixel(m_pixels[i]); - apply->addPixel(0); - } - } - } - apply->setPoints(cb->point1(), cb->point2()); - auto restore = std::make_unique(*cb); - m_cmdStack->push(new PasteClipboardCommand(this, std::move(restore), std::move(apply))); -} - -void SheetData::copyToClipboard() { - m_clipboard.setPoints(m_selectionStart, m_selectionEnd); - copyToClipboard(&m_clipboard); -} - -void SheetData::copyToClipboard(TileSheetClipboard *cb) { - const auto p1 = cb->point1(); - const auto p2 = cb->point2(); - for (int x = p1.x; x <= p2.x; ++x) { - for (int y = p1.y; y <= p2.y; ++y) { - const auto pt = common::Point(x, y); - const auto idx = ptToIdx(pt, m_columns); - cb->addPixel(m_pixels[idx]); - } - } -} - -void SheetData::pasteClipboard() { - auto apply = std::make_unique(m_clipboard); - auto restore = std::make_unique(); - const auto p2 = m_selectionStart + (apply->point2() - apply->point1()); - apply->setPoints(m_selectionStart, p2); - restore->setPoints(m_selectionStart, p2); - markSelection(p2); - copyToClipboard(restore.get()); - m_cmdStack->push(new PasteClipboardCommand(this, std::move(restore), std::move(apply))); -} - -void SheetData::applyClipboard(const TileSheetClipboard &cb) { - cb.pastePixels(cb.point1(), &m_pixels, m_columns); - notifyUpdate(); -} - -void SheetData::markSelection(common::Point selectionEnd) { - // mark selection - m_selectionEnd = selectionEnd; - ox::memsetElements(m_pixelSelected.data(), 0, static_cast(m_pixelSelected.size())); - for (auto x = m_selectionStart.x; x <= m_selectionEnd.x; ++x) { - for (auto y = m_selectionStart.y; y <= m_selectionEnd.y; ++y) { - m_pixelSelected[ptToIdx(x, y, m_columns)] |= 1; - } - } - emit pixelSelectedChanged((m_selectionEnd.x - m_selectionStart.x + 1) * (m_selectionEnd.y - m_selectionStart.y + 1)); -} - -void SheetData::setColumns(int columns) { - m_columns = columns; - emit columnsChanged(columns); - emit changeOccurred(); -} - -void SheetData::setRows(int rows) { - m_rows = rows; - emit rowsChanged(rows); - emit changeOccurred(); -} - -void SheetData::updateColumns(int columns) { - m_cmdStack->push(new UpdateDimensionsCommand(this, UpdateDimensionsCommand::Dimension::Columns, m_columns, columns)); -} - -void SheetData::updateRows(int rows) { - m_cmdStack->push(new UpdateDimensionsCommand(this, UpdateDimensionsCommand::Dimension::Rows, m_rows, rows)); -} - -void SheetData::setActiveTool(int t) { - m_activeTool = static_cast(t); - ox::memsetElements(m_pixelSelected.data(), 0, static_cast(m_pixelSelected.size())); - emit pixelSelectedChanged(0); -} - -void SheetData::updatePixels(const NostalgiaGraphic *ng) { - m_pixels.clear(); - m_pixelSelected.clear(); - if (ng->bpp == 8) { - for (const auto &c : ng->pixels) { - m_pixels.push_back(c); - m_pixelSelected.push_back(0); - } - } else { - for (std::size_t i = 0; i < ng->pixels.size() * 2; i++) { - uint8_t p; - if (i & 1) { - p = ng->pixels[i / 2] >> 4; - } else { - p = ng->pixels[i / 2] & 0xF; - } - m_pixels.push_back(p); - m_pixelSelected.push_back(0); - } - } - emit pixelsChanged(); -} - -const char *SheetData::activeToolString() const { - return toString(m_activeTool); -} - -TileSheetEditor::TileSheetEditor(QString path, const studio::Context *ctx, QWidget *parent): studio::Editor(parent), m_sheetData(undoStack()) { - m_ctx = ctx; +TileSheetEditor::TileSheetEditor(Context *ctx, const ox::String &path) { m_itemPath = path; - m_itemName = path.mid(path.lastIndexOf('/')); - auto lyt = new QVBoxLayout(this); - m_splitter = new QSplitter(this); - auto canvasParent = new QWidget(m_splitter); - auto canvasLyt = new QVBoxLayout(canvasParent); - m_canvas = new QQuickWidget(canvasParent); - canvasLyt->addWidget(m_canvas); - auto tb = new QToolBar(tr("Tile Sheet Options")); - m_tilesX = new LabeledSpinner(tr("Tiles &X:"), 1, m_sheetData.columns()); - m_tilesY = new LabeledSpinner(tr("Tiles &Y:"), 1, m_sheetData.rows()); - auto updateAfterBtn = new QPushButton(tr("&Mod GTE"), tb); - m_toolBtns.addButton(new QPushButton(tr("&Select"), tb), static_cast(TileSheetTool::Select)); - m_toolBtns.addButton(new QPushButton(tr("&Draw"), tb), static_cast(TileSheetTool::Draw)); - m_toolBtns.addButton(new QPushButton(tr("F&ill"), tb), static_cast(TileSheetTool::Fill)); - tb->addWidget(m_tilesX); - tb->addWidget(m_tilesY); - tb->addSeparator(); - tb->addWidget(updateAfterBtn); - tb->addSeparator(); - for (auto btn : m_toolBtns.buttons()) { - btn->setCheckable(true); - tb->addWidget(btn); - } - m_toolBtns.button(m_sheetData.activeTool())->setChecked(true); - connect(&m_toolBtns, &QButtonGroup::idClicked, &m_sheetData, &SheetData::setActiveTool); - canvasLyt->setMenuBar(tb); - lyt->addWidget(m_splitter); - m_splitter->addWidget(canvasParent); - m_splitter->addWidget(setupColorPicker(m_splitter)); - m_splitter->setStretchFactor(0, 1); - connect(&m_sheetData, &SheetData::columnsChanged, [this](int val) { - disconnect(m_tilesX->spinBox, QOverload::of(&QSpinBox::valueChanged), &m_sheetData, &SheetData::updateColumns); - m_tilesX->spinBox->setValue(val); - connect(m_tilesX->spinBox, QOverload::of(&QSpinBox::valueChanged), &m_sheetData, &SheetData::updateColumns); - }); - connect(&m_sheetData, &SheetData::rowsChanged, [this](int val) { - disconnect(m_tilesY->spinBox, QOverload::of(&QSpinBox::valueChanged), &m_sheetData, &SheetData::updateRows); - m_tilesY->spinBox->setValue(val); - connect(m_tilesY->spinBox, QOverload::of(&QSpinBox::valueChanged), &m_sheetData, &SheetData::updateRows); - }); - m_sheetData.load(m_ctx, m_itemPath); - connect(m_tilesX->spinBox, QOverload::of(&QSpinBox::valueChanged), &m_sheetData, &SheetData::updateColumns); - connect(m_tilesY->spinBox, QOverload::of(&QSpinBox::valueChanged), &m_sheetData, &SheetData::updateRows); - connect(updateAfterBtn, &QPushButton::clicked, this, &TileSheetEditor::updateAfterClicked); - m_canvas->rootContext()->setContextProperty("sheetData", &m_sheetData); - m_canvas->setSource(QUrl::fromLocalFile(":/qml/TileSheetEditor.qml")); - m_canvas->setResizeMode(QQuickWidget::SizeRootObjectToView); - setPalette(); - setColorTable(); - restoreState(); - connect(&m_sheetData, &SheetData::changeOccurred, [this] { setUnsavedChanges(true); }); - connect(&m_sheetData, &SheetData::paletteChanged, this, &TileSheetEditor::setColorTable); - connect(&m_sheetData, &SheetData::pixelSelectedChanged, [this](int selected) { - setCutEnabled(selected); - setCopyEnabled(selected); - setPasteEnabled(selected && !m_sheetData.clipboardEmpty()); - }); - setExportable(true); - installEventFilter(this); + const auto lastSlash = std::find(m_itemPath.crbegin(), m_itemPath.crend(), '/').offset(); + m_itemName = m_itemPath.substr(lastSlash + 1); + m_ctx = ctx; + // build shaders + oxThrowError(m_pixels.buildShader()); + oxThrowError(m_pixelGrid.buildShader()); + oxRequireT(img, readObj(ctx, m_itemPath.c_str())); + oxThrowError(readObj(ctx, img->defaultPalette).moveTo(&m_pal)); + m_img = *img; } -TileSheetEditor::~TileSheetEditor() { - saveState(); +ox::String TileSheetEditor::itemName() const noexcept { + return m_itemPath; } -QString TileSheetEditor::itemName() const { +ox::String TileSheetEditor::itemDisplayName() const noexcept { return m_itemName; } void TileSheetEditor::exportFile() { - auto path = QFileDialog::getSaveFileName(this, tr("Export to Image"), "", - tr("PNG (*.png)")); - if (path != "") { - auto ng = m_sheetData.toNostalgiaGraphic(); - QString palPath; - if (palPath == "" && ng->defaultPalette.type() == ox::FileAddressType::Path) { - palPath = ng->defaultPalette.getPath().value; - } - std::unique_ptr npal; - try { - npal = m_ctx->project->loadObj(palPath); - } catch (ox::Exception&) { - qWarning() << "Could not open palette" << palPath; - // TODO: message box to notify of failure - } - toQImage(ng.get(), npal.get()).save(path, "PNG"); - } } void TileSheetEditor::cut() { - m_sheetData.cutToClipboard(); } void TileSheetEditor::copy() { - m_sheetData.copyToClipboard(); } void TileSheetEditor::paste() { - m_sheetData.pasteClipboard(); +} + +void TileSheetEditor::draw(core::Context*) noexcept { + const auto size = ImGui::GetContentRegionAvail(); + const auto sizei = common::Size(static_cast(size.x), static_cast(size.y)); + if (m_framebuffer.width != sizei.width || m_framebuffer.height != sizei.height) { + m_framebuffer = glutils::generateFrameBuffer(sizei.width, sizei.height); + m_pixels.initBufferSet(m_img, *m_pal); + m_pixelGrid.initBufferSet(m_img); + } + glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer); + glViewport(0, 0, sizei.width, sizei.height); + glDraw(); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + ImGui::Image(reinterpret_cast(m_framebuffer.color.id), size, ImVec2(0, 1), ImVec2(1, 0)); +} + +void TileSheetEditor::glDraw() noexcept { + // clear screen + constexpr Color32 bgColor = 0x717d7e; + glClearColor(redf(bgColor), greenf(bgColor), bluef(bgColor), 1.f); + glClear(GL_COLOR_BUFFER_BIT); + m_pixels.draw(m_updated); + m_pixelGrid.draw(m_updated); + m_updated = false; + //oxAssert(glGetError() == 0, "There was an OpenGL error"); } void TileSheetEditor::saveItem() { - m_sheetData.save(m_ctx, m_itemPath); -} - -bool TileSheetEditor::eventFilter(QObject *o, QEvent *e) { - if (e->type() == QEvent::KeyPress) { - const auto k = static_cast(e)->key(); - const auto max = m_colorPicker.colorTable->rowCount() - 1; - if (k >= Qt::Key_0 && k <= Qt::Key_9) { - const auto val = k - Qt::Key_1 + (k == Qt::Key_0 ? 10 : 0); - m_colorPicker.colorTable->setCurrentCell(std::min(max, val), 0); - return true; - } - } - return QWidget::eventFilter(o, e); -} - -QWidget *TileSheetEditor::setupColorPicker(QWidget *parent) { - auto colorPicker = new QWidget(parent); - auto lyt = new QVBoxLayout(colorPicker); - m_colorPicker.palette = new QComboBox(colorPicker); - m_colorPicker.colorTable = new QTableWidget(colorPicker); - m_colorPicker.colorTable->setItemDelegate(&m_colorTableDelegate); - m_colorPicker.colorTable->setColumnCount(2); - m_colorPicker.colorTable->setSelectionBehavior(QAbstractItemView::SelectRows); - m_colorPicker.colorTable->setSelectionMode(QAbstractItemView::SingleSelection); - m_colorPicker.colorTable->setHorizontalHeaderLabels(QStringList() << tr("Hex Code") << tr("Color")); - m_colorPicker.colorTable->horizontalHeader()->setStretchLastSection(true); - connect(m_colorPicker.colorTable, &QTableWidget::itemSelectionChanged, this, &TileSheetEditor::colorSelected); - connect(m_colorPicker.palette, &QComboBox::currentTextChanged, this, [this](QString name) { - m_sheetData.setPalette(m_ctx, palettePath(name)); - }); - lyt->addWidget(m_colorPicker.palette); - lyt->addWidget(m_colorPicker.colorTable); - m_ctx->project->subscribe(studio::ProjectEvent::FileRecognized, m_colorPicker.palette, [this](QString path) { - if (path.startsWith(PaletteDir) && path.endsWith(FileExt_npal)) { - auto name = paletteName(path); - m_colorPicker.palette->addItem(name); - } - }); - m_ctx->project->subscribe(studio::ProjectEvent::FileUpdated, m_colorPicker.palette, [this](QString path) { - if (path == m_sheetData.palettePath()) { - m_sheetData.reload(m_ctx); - } - }); - m_ctx->project->subscribe(studio::ProjectEvent::FileDeleted, m_colorPicker.palette, [this](QString path) { - if (path.startsWith(PaletteDir) && path.endsWith(FileExt_npal)) { - auto name = paletteName(path); - auto idx = m_colorPicker.palette->findText(name); - m_colorPicker.palette->removeItem(idx); - } - }); - return colorPicker; -} - -void TileSheetEditor::setPalette() { - auto name = paletteName(m_sheetData.palettePath()); - m_colorPicker.palette->setCurrentText(name); -} - -void TileSheetEditor::saveState() { - QSettings settings(m_ctx->orgName, ModuleName); - settings.beginGroup("TileSheetEditor/" + m_itemName); - settings.setValue("m_splitter/state", m_splitter->saveState()); - settings.setValue("m_sheetData/tileRows", m_sheetData.rows()); - settings.setValue("m_sheetData/tileColumns", m_sheetData.columns()); - settings.setValue("m_colorPicker.colorTable/geometry", m_colorPicker.colorTable->horizontalHeader()->saveState()); - settings.endGroup(); -} - -void TileSheetEditor::restoreState() { - QSettings settings(m_ctx->orgName, ModuleName); - settings.beginGroup("TileSheetEditor/" + m_itemName); - m_splitter->restoreState(settings.value("m_splitter/state", m_splitter->saveState()).toByteArray()); - m_colorPicker.colorTable->horizontalHeader()->restoreState(settings.value("m_colorPicker.colorTable/geometry", m_colorPicker.colorTable->horizontalHeader()->saveState()).toByteArray()); - settings.endGroup(); -} - -QString TileSheetEditor::paletteName(QString palettePath) const { - return studio::filePathToName(palettePath, PaletteDir, FileExt_npal); -} - -QString TileSheetEditor::palettePath(QString paletteName) const { - return PaletteDir + paletteName + FileExt_npal; -} - -QImage TileSheetEditor::toQImage(NostalgiaGraphic *ng, NostalgiaPalette *npal) const { - const auto w = ng->columns * TileWidth; - const auto h = ng->rows * TileHeight; - QImage dst(w, h, QImage::Format_RGB32); - auto setPixel = [&dst, npal, ng](std::size_t i, uint8_t p) { - const auto color = toColor32(npal->colors[p]) >> 8; - const auto pt = idxToPt(i, ng->columns); - dst.setPixel(pt.x, pt.y, color); - }; - if (ng->bpp == 4) { - for (std::size_t i = 0; i < ng->pixels.size(); ++i) { - auto p1 = ng->pixels[i] & 0xF; - auto p2 = ng->pixels[i] >> 4; - setPixel(i * 2 + 0, p1); - setPixel(i * 2 + 1, p2); - } - } else { - for (std::size_t i = 0; i < ng->pixels.size(); i++) { - const auto p = ng->pixels[i]; - setPixel(i, p); - } - } - return dst; -} - -void TileSheetEditor::colorSelected() { - m_sheetData.setSelectedColor(m_colorPicker.colorTable->currentRow()); -} - -void TileSheetEditor::setColorTable() { - auto hexColors = m_sheetData.palette(); - auto tbl = m_colorPicker.colorTable; - tbl->setRowCount(hexColors.size()); - for (int i = 0; i < hexColors.size(); i++) { - auto hexCode = new QTableWidgetItem; - hexCode->setText(hexColors[i]); - hexCode->setFont(QFont("monospace")); - tbl->setItem(i, 0, hexCode); - auto hi = tbl->item(i, 0); - hi->setFlags(hi->flags() & ~Qt::ItemIsEditable); - auto color = new QTableWidgetItem; - color->setText(hexColors[i]); - tbl->setItem(i, 1, color); - auto ci = tbl->item(i, 1); - ci->setFlags(ci->flags() & ~Qt::ItemIsEditable); - } -} - -void TileSheetEditor::updateAfterClicked() { - auto d = new ModAfterDialog(m_sheetData.palette(), this); - connect(d, &ModAfterDialog::accepted, [this, d] { - auto mod = d->mod(); - if (mod) { - m_sheetData.modGteCmd(d->color(), mod); - } - }); - connect(d, &ModAfterDialog::finished, d, &ModAfterDialog::deleteLater); - d->open(); } } diff --git a/src/nostalgia/core/studio/tilesheeteditor.hpp b/src/nostalgia/core/studio/tilesheeteditor.hpp index db796c46..b942fabd 100644 --- a/src/nostalgia/core/studio/tilesheeteditor.hpp +++ b/src/nostalgia/core/studio/tilesheeteditor.hpp @@ -1,23 +1,17 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once -#include -#include -#include -#include -#include - #include #include +#include #include +#include "tilesheetpixelgrid.hpp" +#include "tilesheetpixels.hpp" + namespace nostalgia::core { // Command IDs to use with QUndoCommand::id() @@ -35,7 +29,8 @@ enum class TileSheetTool: int { Fill, }; -[[nodiscard]] constexpr auto toString(TileSheetTool t) noexcept { +[[nodiscard]] +constexpr auto toString(TileSheetTool t) noexcept { switch (t) { case TileSheetTool::Select: return "Select"; @@ -49,14 +44,13 @@ enum class TileSheetTool: int { struct PixelChunk { static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.PixelChunk"; - static constexpr auto Fields = 2; static constexpr auto TypeVersion = 1; common::Point pt; int size = 0; }; template -ox::Error model(T *io, PixelChunk *c) { +constexpr ox::Error model(T *io, PixelChunk *c) noexcept { io->template setTypeInfo(); oxReturnError(io->field("pt", &c->pt)); oxReturnError(io->field("size", &c->size)); @@ -65,29 +59,31 @@ ox::Error model(T *io, PixelChunk *c) { struct TileSheetClipboard { static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetClipboard"; - static constexpr auto Fields = 3; static constexpr auto TypeVersion = 1; template friend ox::Error model(T*, TileSheetClipboard*); protected: - std::vector m_pixels; + ox::Vector m_pixels; common::Point m_p1; common::Point m_p2; public: void addPixel(int color); - [[nodiscard]] bool empty() const; + [[nodiscard]] + bool empty() const; - void pastePixels(common::Point pt, QVector *tgt, int tgtColumns) const; + void pastePixels(common::Point pt, ox::Vector *tgt, int tgtColumns) const; void setPoints(common::Point p1, common::Point p2); - [[nodiscard]] common::Point point1() const; + [[nodiscard]] + common::Point point1() const; - [[nodiscard]] common::Point point2() const; + [[nodiscard]] + common::Point point2() const; }; @@ -100,176 +96,27 @@ ox::Error model(T *io, TileSheetClipboard *b) { return OxError(0); } -struct TileSheetEditorColorTableDelegate: public QStyledItemDelegate { - - void paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &idx) const; - -}; - -class SheetData: public QObject { - Q_OBJECT - Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged) - Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged) - Q_PROPERTY(QVector pixelSelected READ pixelSelected NOTIFY pixelSelectedChanged) - Q_PROPERTY(QVector pixels READ pixels NOTIFY pixelsChanged) - Q_PROPERTY(QStringList palette READ palette NOTIFY paletteChanged) - Q_PROPERTY(QString activeTool READ activeToolString) - - private: - class QQuickItem *m_prevPixelOperand = nullptr; - QString m_tilesheetPath; - QString m_currentPalettePath; - uint64_t m_cmdIdx = 0; - QUndoStack *m_cmdStack; - QStringList m_palette; - QVector m_pixelSelected; - QVector m_pixels; - common::Point m_selectionStart = {-1, -1}; - common::Point m_selectionEnd = {-1, -1}; - int m_columns = 1; - int m_rows = 1; - int m_selectedColor = 0; - TileSheetTool m_activeTool = TileSheetTool::Draw; - TileSheetClipboard m_clipboard; - - public: - explicit SheetData(QUndoStack*); - - Q_INVOKABLE void fillPixel(QVariant pixel); - - Q_INVOKABLE void selectPixel(QVariant pixel); - - Q_INVOKABLE void updatePixel(QVariant pixel); - - Q_INVOKABLE void beginCmd(); - - Q_INVOKABLE void endCmd(); - - Q_INVOKABLE void insertTileCmd(int tileIdx); - - Q_INVOKABLE void deleteTileCmd(int tileIdx); - - [[nodiscard]] int columns() const; - - [[nodiscard]] int rows() const; - - [[nodiscard]] const QVector &pixelSelected() const; - - [[nodiscard]] const QVector &pixels() const; - - [[nodiscard]] QStringList palette() const; - - [[nodiscard]] QString palettePath() const; - - void getFillPixels(bool *pixels, common::Point pt, int oldColor) const; - - void load(const studio::Context *ctx, QString ngPath, QString palPath = ""); - - void reload(const studio::Context *ctx); - - void save(const studio::Context *ctx, QString ngPath) const; - - void setPalette(const NostalgiaPalette *pal); - - void setPalette(const studio::Context *ctx, QString palPath); - - void insertTile(int tileIdx, QVector tileData = {}); - - QVector deleteTile(int tileIdx); - - void setSelectedColor(int index); - - void modGteCmd(int val, int mod); - - void modPixels(const QHash &pixels, int inversion); - - void setPixel(int index, int color); - - void notifyUpdate(); - - [[nodiscard]] std::unique_ptr toNostalgiaGraphic() const; - - [[nodiscard]] int activeTool() const; - - [[nodiscard]] bool clipboardEmpty() const; - - void cutToClipboard(); - - void cutToClipboard(TileSheetClipboard *cb); - - void copyToClipboard(); - - void copyToClipboard(TileSheetClipboard *cb); - - void pasteClipboard(); - - void applyClipboard(const TileSheetClipboard &cb); - - void markSelection(common::Point selectionEnd); - - public slots: - void setColumns(int columns); - - void setRows(int rows); - - /** - * Sets columns through a QUndoCommand. - */ - void updateColumns(int columns); - - /** - * Sets rows through a QUndoCommand. - */ - void updateRows(int rows); - - void setActiveTool(int t); - - private: - void updatePixels(const NostalgiaGraphic *ng); - - const char *activeToolString() const; - - signals: - void changeOccurred(); - - void columnsChanged(int); - - void rowsChanged(int); - - void pixelSelectedChanged(int pixelsSelected); - - void pixelsChanged(); - - void paletteChanged(); - -}; - - class TileSheetEditor: public studio::Editor { - Q_OBJECT private: - TileSheetEditorColorTableDelegate m_colorTableDelegate; - QString m_itemPath; - QString m_itemName; - const studio::Context *m_ctx = nullptr; - SheetData m_sheetData; - QButtonGroup m_toolBtns; - class QSplitter *m_splitter = nullptr; - struct LabeledSpinner *m_tilesX = nullptr; - struct LabeledSpinner *m_tilesY = nullptr; - class QQuickWidget* m_canvas = nullptr; - struct { - QComboBox *palette = nullptr; - class QTableWidget *colorTable = nullptr; - } m_colorPicker; + ox::String m_itemPath; + ox::String m_itemName; + glutils::FrameBuffer m_framebuffer; + TileSheetGrid m_pixelGrid; + TileSheetPixels m_pixels; + bool m_updated = false; + NostalgiaGraphic m_img; + AssetRef m_pal; + Context *m_ctx = nullptr; public: - TileSheetEditor(QString path, const studio::Context *ctx, QWidget *parent); + TileSheetEditor(Context *ctx, const ox::String &path); - virtual ~TileSheetEditor(); + ~TileSheetEditor() override = default; - QString itemName() const override; + ox::String itemName() const noexcept override; + + ox::String itemDisplayName() const noexcept override; void exportFile() override; @@ -279,34 +126,36 @@ class TileSheetEditor: public studio::Editor { void paste() override; + void draw(core::Context*) noexcept override; + + void glDraw() noexcept; + protected: void saveItem() override; - bool eventFilter(QObject *obj, QEvent *event) override; - private: - QWidget *setupColorPicker(QWidget *widget); - void setPalette(); void saveState(); void restoreState(); - [[nodiscard]] QString paletteName(QString palettePath) const; + [[nodiscard]] + ox::String paletteName(const ox::String &palettePath) const; - [[nodiscard]] QString palettePath(QString palettePath) const; + [[nodiscard]] + ox::String palettePath(const ox::String &palettePath) const; - [[nodiscard]] QImage toQImage(NostalgiaGraphic *ng, NostalgiaPalette *npal) const; + // slots + public: + ox::Error colorSelected() noexcept; - public slots: - void colorSelected(); + ox::Error setColorTable() noexcept; - void setColorTable(); - - private slots: - void updateAfterClicked(); + // slots + private: + ox::Error updateAfterClicked() noexcept; }; -} +} \ No newline at end of file diff --git a/src/nostalgia/core/studio/tilesheetpixelgrid.cpp b/src/nostalgia/core/studio/tilesheetpixelgrid.cpp new file mode 100644 index 00000000..98ed5923 --- /dev/null +++ b/src/nostalgia/core/studio/tilesheetpixelgrid.cpp @@ -0,0 +1,90 @@ +/* + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include +#include "tilesheetpixelgrid.hpp" + +namespace nostalgia::core { + +ox::Error TileSheetGrid::buildShader() noexcept { + const auto pixelLineVshad = ox::sfmt(VShad, glutils::GlslVersion); + const auto pixelLineFshad = ox::sfmt(FShad, glutils::GlslVersion); + const auto pixelLineGshad = ox::sfmt(GShad, glutils::GlslVersion); + return glutils::buildShaderProgram(pixelLineVshad, pixelLineFshad, pixelLineGshad).moveTo(&m_shader); +} + +void TileSheetGrid::draw(bool update) noexcept { + glUseProgram(m_shader); + glBindVertexArray(m_bufferSet.vao); + if (update) { + glutils::sendVbo(m_bufferSet); + } + glDrawElements(GL_POINTS, static_cast(m_bufferSet.elements.size()), GL_UNSIGNED_INT, nullptr); +} + +void TileSheetGrid::initBufferSet(const NostalgiaGraphic &img) noexcept { + // vao + m_bufferSet.vao = glutils::generateVertexArrayObject(); + glBindVertexArray(m_bufferSet.vao); + // vbo & ebo + m_bufferSet.vbo = glutils::generateBuffer(); + m_bufferSet.ebo = glutils::generateBuffer(); + setBufferObjects(img, &m_bufferSet); + glutils::sendVbo(m_bufferSet); + glutils::sendEbo(m_bufferSet); + // vbo layout + const auto pt1Attr = static_cast(glGetAttribLocation(m_shader, "vPt1")); + glEnableVertexAttribArray(pt1Attr); + glVertexAttribPointer(pt1Attr, 2, GL_FLOAT, GL_FALSE, VertexVboRowLength * sizeof(float), nullptr); + const auto pt2Attr = static_cast(glGetAttribLocation(m_shader, "vPt2")); + glEnableVertexAttribArray(pt2Attr); + glVertexAttribPointer(pt2Attr, 2, GL_FLOAT, GL_FALSE, VertexVboRowLength * sizeof(float), + reinterpret_cast(2 * sizeof(float))); +} + +void TileSheetGrid::setBufferObject(unsigned vertexRow, common::Point pt1, common::Point pt2, float *vbo, GLuint *ebo) noexcept { + const auto ps = pixelSize(); + const auto x1 = static_cast(pt1.x) * ps.x; + const auto y1 = static_cast(pt1.y) * ps.y; + const auto x2 = static_cast(pt2.x) * ps.x; + const auto y2 = static_cast(pt2.y) * ps.y; + // don't worry, these memcpys gets optimized to something much more ideal + const float vertices[VertexVboLength] = {x1, y1, x2, y2}; + memcpy(vbo, vertices, sizeof(vertices)); + const GLuint elms[VertexEboLength] = {vertexRow}; + memcpy(ebo, elms, sizeof(elms)); +} + +void TileSheetGrid::setBufferObjects(const NostalgiaGraphic &img, glutils::BufferSet *bg) noexcept { + const auto set = [bg](unsigned i, common::Point pt1, common::Point pt2) { + const auto vbo = &bg->vertices[i * VertexVboLength]; + const auto ebo = &bg->elements[i * VertexEboLength]; + setBufferObject(i * VertexVboRows, pt1, pt2, vbo, ebo); + }; + // set buffer lengths + const auto width = img.columns * TileWidth; + const auto height = img.rows * TileHeight; + const auto tiles = static_cast(width * height); + m_bufferSet.vertices.resize(tiles * VertexVboLength); + m_bufferSet.elements.resize(tiles * VertexEboLength); + // set buffers + auto i = 0ull; + for (auto x = 0; x < img.columns; ++x) { + set(0, {x, 0}, {x, img.rows}); + ++i; + } + for (auto y = 0; y < img.rows; ++y) { + set(0, {0, y}, {img.columns, y}); + ++i; + } +} + +ImVec2 TileSheetGrid::pixelSize() noexcept { + const auto [sw, sh] = ImGui::GetContentRegionAvail(); + constexpr float ymod = 0.35f / 10.0f; + const auto xmod = ymod * sh / sw; + return {xmod, ymod}; +} + +} diff --git a/src/nostalgia/core/studio/tilesheetpixelgrid.hpp b/src/nostalgia/core/studio/tilesheetpixelgrid.hpp new file mode 100644 index 00000000..a9161e80 --- /dev/null +++ b/src/nostalgia/core/studio/tilesheetpixelgrid.hpp @@ -0,0 +1,80 @@ +/* + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#pragma once + +#include + +#include +#include +#include +#include + +namespace nostalgia::core { + +class TileSheetGrid { + + private: + static constexpr auto VertexVboRows = 1; + static constexpr auto VertexVboRowLength = 4; + static constexpr auto VertexVboLength = VertexVboRows * VertexVboRowLength; + static constexpr auto VertexEboLength = 1; + + static constexpr auto VShad = R"( + {} + in vec2 vPt1; + in vec2 vPt2; + out VS_OUT { + vec2 pt1; + vec2 pt2; + } vs_out; + void main() { + vs_out.pt1 = vPt1; + vs_out.pt2 = vPt2; + gl_Position = vec4(vPt1, 0.0, 1.0); + })"; + + static constexpr auto FShad = R"( + {} + in vec3 fColor; + out vec4 outColor; + void main() { + outColor = vec4(0.4431, 0.4901, 0.4941, 1.0); + })"; + + static constexpr auto GShad = R"glsl( + {} + in VS_OUT { + vec2 pt1; + vec2 pt2; + } gs_in[]; + layout(line_strip, max_vertices = 2) out; + void main() { + //gl_Position = vec4(gs_in[0].pt1, 0, 0); + //EmitVertex(); + //gl_Position = vec4(gs_in[0].pt2, 0, 0); + //EmitVertex(); + //EndPrimitive(); + })glsl"; + + glutils::GLProgram m_shader; + glutils::BufferSet m_bufferSet; + + public: + ox::Error buildShader() noexcept; + + void draw(bool update) noexcept; + + void initBufferSet(const NostalgiaGraphic &img) noexcept; + + private: + static void setBufferObject(unsigned vertexRow, common::Point pt1, common::Point pt2, float *vbo, GLuint *ebo) noexcept; + + void setBufferObjects(const NostalgiaGraphic &img, glutils::BufferSet *bg) noexcept; + + static class ImVec2 pixelSize() noexcept; + +}; + +} diff --git a/src/nostalgia/core/studio/tilesheetpixels.cpp b/src/nostalgia/core/studio/tilesheetpixels.cpp new file mode 100644 index 00000000..d07d56d5 --- /dev/null +++ b/src/nostalgia/core/studio/tilesheetpixels.cpp @@ -0,0 +1,108 @@ +/* + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include +#include "ptidxconv.hpp" +#include "tilesheetpixels.hpp" + +namespace nostalgia::core { + +ox::Error TileSheetPixels::buildShader() noexcept { + const auto Vshad = ox::sfmt(VShad, glutils::GlslVersion); + const auto Fshad = ox::sfmt(FShad, glutils::GlslVersion); + return glutils::buildShaderProgram(Vshad, Fshad).moveTo(&m_shader); +} + +void TileSheetPixels::draw(bool update) noexcept { + glUseProgram(m_shader); + glBindVertexArray(m_bufferSet.vao); + if (update) { + glutils::sendVbo(m_bufferSet); + } + glDrawElements(GL_TRIANGLES, static_cast(m_bufferSet.elements.size()), GL_UNSIGNED_INT, nullptr); +} + +void TileSheetPixels::initBufferSet(const NostalgiaGraphic &img, const NostalgiaPalette &pal) noexcept { + // vao + m_bufferSet.vao = glutils::generateVertexArrayObject(); + glBindVertexArray(m_bufferSet.vao); + // vbo & ebo + m_bufferSet.vbo = glutils::generateBuffer(); + m_bufferSet.ebo = glutils::generateBuffer(); + setBufferObjects(img, pal, &m_bufferSet); + glutils::sendVbo(m_bufferSet); + glutils::sendEbo(m_bufferSet); + // vbo layout + const auto posAttr = static_cast(glGetAttribLocation(m_shader, "vPosition")); + glEnableVertexAttribArray(posAttr); + glVertexAttribPointer(posAttr, 2, GL_FLOAT, GL_FALSE, VertexVboRowLength * sizeof(float), nullptr); + const auto colorAttr = static_cast(glGetAttribLocation(m_shader, "vColor")); + glEnableVertexAttribArray(colorAttr); + glVertexAttribPointer(colorAttr, 3, GL_FLOAT, GL_FALSE, VertexVboRowLength * sizeof(float), + reinterpret_cast(2 * sizeof(float))); +} + +void TileSheetPixels::setPixelBufferObject(unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) noexcept { + const auto [xmod, ymod] = pixelSize(); + x *= xmod; + y *= -ymod; + x -= 1.0f; + y += 1.0f - ymod; + //std::cout << x << ", " << y << ", " << (x + xmod) << ", " << (y + ymod) << '\n'; + const auto r = redf(color), g = greenf(color), b = bluef(color); + // don't worry, these memcpys gets optimized to something much more ideal + const float vertices[VertexVboLength] = { + x, y, r, g, b, // bottom left + x + xmod, y, r, g, b, // bottom right + x + xmod, y + ymod, r, g, b, // top right + x, y + ymod, r, g, b, // top left + }; + memcpy(vbo, vertices, sizeof(vertices)); + const GLuint elms[VertexEboLength] = { + vertexRow + 0, vertexRow + 1, vertexRow + 2, + vertexRow + 2, vertexRow + 3, vertexRow + 0, + }; + memcpy(ebo, elms, sizeof(elms)); +} + +void TileSheetPixels::setBufferObjects(const NostalgiaGraphic &img, const NostalgiaPalette &pal, glutils::BufferSet *bg) noexcept { + const auto setPixel = [bg, img, pal](std::size_t i, uint8_t p) { + const auto color = pal.colors[p]; + const auto pt = idxToPt(i, img.columns); + const auto fx = static_cast(pt.x); + const auto fy = static_cast(pt.y); + const auto vbo = &bg->vertices[i * VertexVboLength]; + const auto ebo = &bg->elements[i * VertexEboLength]; + setPixelBufferObject(i * VertexVboRows, fx, fy, color, vbo, ebo); + }; + // set buffer lengths + const auto width = img.columns * TileWidth; + const auto height = img.rows * TileHeight; + const auto tiles = static_cast(width * height); + m_bufferSet.vertices.resize(tiles * VertexVboLength); + m_bufferSet.elements.resize(tiles * VertexEboLength); + // set pixels + if (img.bpp == 4) { + for (std::size_t i = 0; i < img.pixels.size(); ++i) { + const auto colorIdx1 = img.pixels[i] & 0xF; + const auto colorIdx2 = img.pixels[i] >> 4; + setPixel(i * 2 + 0, colorIdx1); + setPixel(i * 2 + 1, colorIdx2); + } + } else { + for (std::size_t i = 0; i < img.pixels.size(); ++i) { + const auto p = img.pixels[i]; + setPixel(i, p); + } + } +} + +ImVec2 TileSheetPixels::pixelSize() noexcept { + const auto [sw, sh] = ImGui::GetContentRegionAvail(); + constexpr float ymod = 0.35f / 10.0f; + const auto xmod = ymod * sh / sw; + return {xmod, ymod}; +} + +} diff --git a/src/nostalgia/core/studio/tilesheetpixels.hpp b/src/nostalgia/core/studio/tilesheetpixels.hpp new file mode 100644 index 00000000..4556bbfc --- /dev/null +++ b/src/nostalgia/core/studio/tilesheetpixels.hpp @@ -0,0 +1,59 @@ +/* + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#pragma once + +#include + +#include +#include +#include + +namespace nostalgia::core { + +class TileSheetPixels { + + private: + static constexpr auto VertexVboRows = 4; + static constexpr auto VertexVboRowLength = 5; + static constexpr auto VertexVboLength = VertexVboRows * VertexVboRowLength; + static constexpr auto VertexEboLength = 6; + static constexpr auto VShad = R"( + {} + in vec2 vPosition; + in vec3 vColor; + out vec3 fColor; + void main() { + gl_Position = vec4(vPosition, 0.0, 1.0); + fColor = vColor; + })"; + static constexpr auto FShad = R"( + {} + in vec3 fColor; + out vec4 outColor; + void main() { + //outColor = vec4(0.0, 0.7, 1.0, 1.0); + outColor = vec4(fColor, 1.0); + })"; + + glutils::GLProgram m_shader; + glutils::BufferSet m_bufferSet; + + public: + ox::Error buildShader() noexcept; + + void draw(bool update) noexcept; + + void initBufferSet(const NostalgiaGraphic &img, const NostalgiaPalette &pal) noexcept; + + private: + static void setPixelBufferObject(unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) noexcept; + + void setBufferObjects(const NostalgiaGraphic &img, const NostalgiaPalette &pal, glutils::BufferSet *bg) noexcept; + + static class ImVec2 pixelSize() noexcept; + +}; + +} diff --git a/src/nostalgia/core/studio/util.cpp b/src/nostalgia/core/studio/util.cpp index 8abfd832..31168dad 100644 --- a/src/nostalgia/core/studio/util.cpp +++ b/src/nostalgia/core/studio/util.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "util.hpp" diff --git a/src/nostalgia/core/studio/util.hpp b/src/nostalgia/core/studio/util.hpp index fb0ece16..1dbdac1f 100644 --- a/src/nostalgia/core/studio/util.hpp +++ b/src/nostalgia/core/studio/util.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/userland/gfx.cpp b/src/nostalgia/core/userland/gfx.cpp index c502713a..af9c2057 100644 --- a/src/nostalgia/core/userland/gfx.cpp +++ b/src/nostalgia/core/userland/gfx.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/userland/gfx.hpp b/src/nostalgia/core/userland/gfx.hpp index 51589414..4ce2db37 100644 --- a/src/nostalgia/core/userland/gfx.hpp +++ b/src/nostalgia/core/userland/gfx.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/core/userland/gfx_opengl.cpp b/src/nostalgia/core/userland/gfx_opengl.cpp index bec038aa..5404fa6e 100644 --- a/src/nostalgia/core/userland/gfx_opengl.cpp +++ b/src/nostalgia/core/userland/gfx_opengl.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/core/userland/media.cpp b/src/nostalgia/core/userland/media.cpp index 272ca394..79c118e4 100644 --- a/src/nostalgia/core/userland/media.cpp +++ b/src/nostalgia/core/userland/media.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/glutils/glutils.cpp b/src/nostalgia/glutils/glutils.cpp index 69cd7513..4eff34c0 100644 --- a/src/nostalgia/glutils/glutils.cpp +++ b/src/nostalgia/glutils/glutils.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/glutils/glutils.hpp b/src/nostalgia/glutils/glutils.hpp index 188d3a7f..ffd8b9c5 100644 --- a/src/nostalgia/glutils/glutils.hpp +++ b/src/nostalgia/glutils/glutils.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -26,7 +22,7 @@ namespace nostalgia::glutils { -constexpr auto GlslVersion = "#version 150"; +constexpr auto GlslVersion = "#version 330"; struct Empty {}; diff --git a/src/nostalgia/player/app.cpp b/src/nostalgia/player/app.cpp index ae76bf32..820145cb 100644 --- a/src/nostalgia/player/app.cpp +++ b/src/nostalgia/player/app.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/player/app.hpp b/src/nostalgia/player/app.hpp index 737f3e40..8722a4b9 100644 --- a/src/nostalgia/player/app.hpp +++ b/src/nostalgia/player/app.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/player/main.cpp b/src/nostalgia/player/main.cpp index e3a55560..9ef65cda 100644 --- a/src/nostalgia/player/main.cpp +++ b/src/nostalgia/player/main.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/scene/scene.cpp b/src/nostalgia/scene/scene.cpp index 042f3728..58c04247 100644 --- a/src/nostalgia/scene/scene.cpp +++ b/src/nostalgia/scene/scene.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "scene.hpp" diff --git a/src/nostalgia/scene/scene.hpp b/src/nostalgia/scene/scene.hpp index ecf33de2..bc3c789d 100644 --- a/src/nostalgia/scene/scene.hpp +++ b/src/nostalgia/scene/scene.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/CMakeLists.txt b/src/nostalgia/studio/CMakeLists.txt index 0a8e9bcc..e71f9530 100644 --- a/src/nostalgia/studio/CMakeLists.txt +++ b/src/nostalgia/studio/CMakeLists.txt @@ -43,4 +43,4 @@ install( BUNDLE DESTINATION . ) -add_subdirectory(lib) +add_subdirectory(lib) \ No newline at end of file diff --git a/src/nostalgia/studio/builtinmodules.hpp b/src/nostalgia/studio/builtinmodules.hpp index c5419ce7..0e5e1f51 100644 --- a/src/nostalgia/studio/builtinmodules.hpp +++ b/src/nostalgia/studio/builtinmodules.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -14,11 +10,11 @@ namespace nostalgia { -//[[maybe_unused]] // GCC warns about the existence of this "unused" constexpr list in a header file... -//constexpr auto BuiltinModules = { -// [] { -// return ox::make_unique(); -// }, -//}; +[[maybe_unused]] // GCC warns about the existence of this "unused" constexpr list in a header file... +constexpr auto BuiltinModules = { + [] { + return ox::make_unique(); + }, +}; } \ No newline at end of file diff --git a/src/nostalgia/studio/filedialogmanager.cpp b/src/nostalgia/studio/filedialogmanager.cpp index 4548e9d0..2afd80f0 100644 --- a/src/nostalgia/studio/filedialogmanager.cpp +++ b/src/nostalgia/studio/filedialogmanager.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/studio/filedialogmanager.hpp b/src/nostalgia/studio/filedialogmanager.hpp index 2130a553..fe60ace0 100644 --- a/src/nostalgia/studio/filedialogmanager.hpp +++ b/src/nostalgia/studio/filedialogmanager.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/lib/configio.cpp b/src/nostalgia/studio/lib/configio.cpp index 96211ced..80d86cb4 100644 --- a/src/nostalgia/studio/lib/configio.cpp +++ b/src/nostalgia/studio/lib/configio.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "configio.hpp" diff --git a/src/nostalgia/studio/lib/configio.hpp b/src/nostalgia/studio/lib/configio.hpp index 8762f7e5..b48b5982 100644 --- a/src/nostalgia/studio/lib/configio.hpp +++ b/src/nostalgia/studio/lib/configio.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/lib/editor.cpp b/src/nostalgia/studio/lib/editor.cpp index 558be286..aeaac3a7 100644 --- a/src/nostalgia/studio/lib/editor.cpp +++ b/src/nostalgia/studio/lib/editor.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/studio/lib/editor.hpp b/src/nostalgia/studio/lib/editor.hpp index 42897acc..2f226e90 100644 --- a/src/nostalgia/studio/lib/editor.hpp +++ b/src/nostalgia/studio/lib/editor.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/lib/filedialog.hpp b/src/nostalgia/studio/lib/filedialog.hpp index 3b0c9561..38df7924 100644 --- a/src/nostalgia/studio/lib/filedialog.hpp +++ b/src/nostalgia/studio/lib/filedialog.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/lib/filedialog_gtk.cpp b/src/nostalgia/studio/lib/filedialog_gtk.cpp index 3c4e01c7..0bae219a 100644 --- a/src/nostalgia/studio/lib/filedialog_gtk.cpp +++ b/src/nostalgia/studio/lib/filedialog_gtk.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/studio/lib/module.cpp b/src/nostalgia/studio/lib/module.cpp index 38282eb5..27fae5d4 100644 --- a/src/nostalgia/studio/lib/module.cpp +++ b/src/nostalgia/studio/lib/module.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "module.hpp" diff --git a/src/nostalgia/studio/lib/module.hpp b/src/nostalgia/studio/lib/module.hpp index 83fa31ca..9a5006e4 100644 --- a/src/nostalgia/studio/lib/module.hpp +++ b/src/nostalgia/studio/lib/module.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/lib/project.cpp b/src/nostalgia/studio/lib/project.cpp index 6857e321..97bded26 100644 --- a/src/nostalgia/studio/lib/project.cpp +++ b/src/nostalgia/studio/lib/project.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/studio/lib/project.hpp b/src/nostalgia/studio/lib/project.hpp index 7f40b58c..068a5ec7 100644 --- a/src/nostalgia/studio/lib/project.hpp +++ b/src/nostalgia/studio/lib/project.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/lib/task.cpp b/src/nostalgia/studio/lib/task.cpp index 2b801988..d8d98503 100644 --- a/src/nostalgia/studio/lib/task.cpp +++ b/src/nostalgia/studio/lib/task.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/studio/lib/task.hpp b/src/nostalgia/studio/lib/task.hpp index b5138f1f..313ad70f 100644 --- a/src/nostalgia/studio/lib/task.hpp +++ b/src/nostalgia/studio/lib/task.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/lib/undostack.cpp b/src/nostalgia/studio/lib/undostack.cpp index 2f38bb1e..006508d6 100644 --- a/src/nostalgia/studio/lib/undostack.cpp +++ b/src/nostalgia/studio/lib/undostack.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "undostack.hpp" diff --git a/src/nostalgia/studio/lib/undostack.hpp b/src/nostalgia/studio/lib/undostack.hpp index 68227c97..27f8e9b6 100644 --- a/src/nostalgia/studio/lib/undostack.hpp +++ b/src/nostalgia/studio/lib/undostack.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/lib/widget.cpp b/src/nostalgia/studio/lib/widget.cpp index fd71e3f5..b732e8c6 100644 --- a/src/nostalgia/studio/lib/widget.cpp +++ b/src/nostalgia/studio/lib/widget.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "widget.hpp" diff --git a/src/nostalgia/studio/lib/widget.hpp b/src/nostalgia/studio/lib/widget.hpp index f821cfaa..d0dcd504 100644 --- a/src/nostalgia/studio/lib/widget.hpp +++ b/src/nostalgia/studio/lib/widget.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/lib/window.cpp b/src/nostalgia/studio/lib/window.cpp index 5c72c90f..772d8335 100644 --- a/src/nostalgia/studio/lib/window.cpp +++ b/src/nostalgia/studio/lib/window.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "window.hpp" diff --git a/src/nostalgia/studio/lib/window.hpp b/src/nostalgia/studio/lib/window.hpp index b55a303d..e3bed379 100644 --- a/src/nostalgia/studio/lib/window.hpp +++ b/src/nostalgia/studio/lib/window.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/main.cpp b/src/nostalgia/studio/main.cpp index fed824b5..33b43e4d 100644 --- a/src/nostalgia/studio/main.cpp +++ b/src/nostalgia/studio/main.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/studio/projectexplorer.cpp b/src/nostalgia/studio/projectexplorer.cpp index ed85541d..8c1f0278 100644 --- a/src/nostalgia/studio/projectexplorer.cpp +++ b/src/nostalgia/studio/projectexplorer.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/studio/projectexplorer.hpp b/src/nostalgia/studio/projectexplorer.hpp index d483a04d..b61815ef 100644 --- a/src/nostalgia/studio/projectexplorer.hpp +++ b/src/nostalgia/studio/projectexplorer.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/projecttreemodel.cpp b/src/nostalgia/studio/projecttreemodel.cpp index adc470a7..1c23638f 100644 --- a/src/nostalgia/studio/projecttreemodel.cpp +++ b/src/nostalgia/studio/projecttreemodel.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/studio/projecttreemodel.hpp b/src/nostalgia/studio/projecttreemodel.hpp index bc3ca7ae..b0f6607d 100644 --- a/src/nostalgia/studio/projecttreemodel.hpp +++ b/src/nostalgia/studio/projecttreemodel.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/studio.hpp b/src/nostalgia/studio/studio.hpp index 8667a2c5..2a87a842 100644 --- a/src/nostalgia/studio/studio.hpp +++ b/src/nostalgia/studio/studio.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/studio/studioapp.cpp b/src/nostalgia/studio/studioapp.cpp index 12f33dc8..04056394 100644 --- a/src/nostalgia/studio/studioapp.cpp +++ b/src/nostalgia/studio/studioapp.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include @@ -61,7 +57,7 @@ void StudioUI::update() noexcept { void StudioUI::draw() noexcept { drawMenu(); drawToolbar(); - drawTabs(); + drawTabBar(); for (auto &w : m_widgets) { w->draw(m_ctx); } @@ -128,7 +124,7 @@ void StudioUI::drawToolbar() noexcept { ImGui::End(); } -void StudioUI::drawTabs() noexcept { +void StudioUI::drawTabBar() noexcept { const auto viewport = ImGui::GetMainViewport(); ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x + 316, viewport->Pos.y + 71)); ImGui::SetNextWindowSize(ImVec2(viewport->Size.x - 316, viewport->Size.y - 71)); @@ -140,31 +136,35 @@ void StudioUI::drawTabs() noexcept { ImGui::Begin("TabWindow##MainWindow", nullptr, windowFlags); constexpr auto tabBarFlags = ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_TabListPopupButton; if (ImGui::BeginTabBar("TabBar##TabWindow##MainWindow", tabBarFlags)) { - for (auto it = m_editors.begin(); it != m_editors.end(); ) { - auto const &e = *it; - bool open = true; - if (ImGui::BeginTabItem(e->itemDisplayName().c_str(), &open)) { - e->draw(m_ctx); - ImGui::EndTabItem(); - } - if (!open) { - e->close(); - try { - oxThrowError(m_editors.erase(it).moveTo(&it)); - } catch (const ox::Exception &ex) { - oxErrf("Editor tab deletion failed: {} ({}:{})\n", ex.what(), ex.file, ex.line); - } catch (const std::exception &ex) { - oxErrf("Editor tab deletion failed: {}\n", ex.what()); - } - } else { - ++it; - } - } + drawTabs(); ImGui::EndTabBar(); } ImGui::End(); } +void StudioUI::drawTabs() noexcept { + for (auto it = m_editors.begin(); it != m_editors.end();) { + auto const &e = *it; + bool open = true; + if (ImGui::BeginTabItem(e->itemDisplayName().c_str(), &open)) { + e->draw(m_ctx); + ImGui::EndTabItem(); + } + if (!open) { + e->close(); + try { + oxThrowError(m_editors.erase(it).moveTo(&it)); + } catch (const ox::Exception &ex) { + oxErrf("Editor tab deletion failed: {} ({}:{})\n", ex.what(), ex.file, ex.line); + } catch (const std::exception &ex) { + oxErrf("Editor tab deletion failed: {}\n", ex.what()); + } + } else { + ++it; + } + } +} + void StudioUI::loadEditorMaker(const studio::EditorMaker &editorMaker) noexcept { for (auto &ext : editorMaker.fileTypes) { m_editorMakers[ext] = editorMaker.make; diff --git a/src/nostalgia/studio/studioapp.hpp b/src/nostalgia/studio/studioapp.hpp index 349d784e..c22e43cf 100644 --- a/src/nostalgia/studio/studioapp.hpp +++ b/src/nostalgia/studio/studioapp.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -48,6 +44,8 @@ class StudioUI: public ox::SignalHandler { void drawToolbar() noexcept; + void drawTabBar() noexcept; + void drawTabs() noexcept; void loadEditorMaker(const studio::EditorMaker &editorMaker) noexcept; diff --git a/src/nostalgia/tools/pack.cpp b/src/nostalgia/tools/pack.cpp index 73f3a93e..54ddb483 100644 --- a/src/nostalgia/tools/pack.cpp +++ b/src/nostalgia/tools/pack.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/tools/pack/pack.cpp b/src/nostalgia/tools/pack/pack.cpp index 1b544f18..55b9629c 100644 --- a/src/nostalgia/tools/pack/pack.cpp +++ b/src/nostalgia/tools/pack/pack.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/tools/pack/pack.hpp b/src/nostalgia/tools/pack/pack.hpp index 20fb207a..3d801bbf 100644 --- a/src/nostalgia/tools/pack/pack.hpp +++ b/src/nostalgia/tools/pack/pack.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ namespace nostalgia { diff --git a/src/nostalgia/world/studio/consts.cpp b/src/nostalgia/world/studio/consts.cpp index 9a9560b4..92867487 100644 --- a/src/nostalgia/world/studio/consts.cpp +++ b/src/nostalgia/world/studio/consts.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "consts.hpp" diff --git a/src/nostalgia/world/studio/consts.hpp b/src/nostalgia/world/studio/consts.hpp index f4bb6b9b..2132f953 100644 --- a/src/nostalgia/world/studio/consts.hpp +++ b/src/nostalgia/world/studio/consts.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/world/studio/newworldwizard.cpp b/src/nostalgia/world/studio/newworldwizard.cpp index 770f0ae0..cc5c18c6 100644 --- a/src/nostalgia/world/studio/newworldwizard.cpp +++ b/src/nostalgia/world/studio/newworldwizard.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/world/studio/newworldwizard.hpp b/src/nostalgia/world/studio/newworldwizard.hpp index e99d6005..31fd8edd 100644 --- a/src/nostalgia/world/studio/newworldwizard.hpp +++ b/src/nostalgia/world/studio/newworldwizard.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/world/studio/worldeditor.cpp b/src/nostalgia/world/studio/worldeditor.cpp index b33dbea5..66a4769c 100644 --- a/src/nostalgia/world/studio/worldeditor.cpp +++ b/src/nostalgia/world/studio/worldeditor.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "worldeditor.hpp" diff --git a/src/nostalgia/world/studio/worldeditor.hpp b/src/nostalgia/world/studio/worldeditor.hpp index 5988c7ee..e437bc9a 100644 --- a/src/nostalgia/world/studio/worldeditor.hpp +++ b/src/nostalgia/world/studio/worldeditor.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/world/studio/worldstudioplugin.cpp b/src/nostalgia/world/studio/worldstudioplugin.cpp index c2b0e2e7..462b4602 100644 --- a/src/nostalgia/world/studio/worldstudioplugin.cpp +++ b/src/nostalgia/world/studio/worldstudioplugin.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include diff --git a/src/nostalgia/world/studio/worldstudioplugin.hpp b/src/nostalgia/world/studio/worldstudioplugin.hpp index 2970b64a..000ff894 100644 --- a/src/nostalgia/world/studio/worldstudioplugin.hpp +++ b/src/nostalgia/world/studio/worldstudioplugin.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once diff --git a/src/nostalgia/world/world.cpp b/src/nostalgia/world/world.cpp index 5004dd9c..a8cbfa7b 100644 --- a/src/nostalgia/world/world.cpp +++ b/src/nostalgia/world/world.cpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #include "world.hpp" diff --git a/src/nostalgia/world/world.hpp b/src/nostalgia/world/world.hpp index c6af6254..6d168543 100644 --- a/src/nostalgia/world/world.hpp +++ b/src/nostalgia/world/world.hpp @@ -1,9 +1,5 @@ /* - * Copyright 2016 - 2021 gary@drinkingtea.net - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once