[nostalgia] Start on new TileSheetEditor

This commit is contained in:
Gary Talent 2021-12-17 20:57:56 -06:00
parent ed074d07be
commit 775008a513
122 changed files with 651 additions and 2592 deletions

View File

@ -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.

View File

@ -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)

373
LICENSE
View File

@ -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.

View File

@ -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 = {
}

View File

@ -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)

View File

@ -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"

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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(

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <nostalgia/core/config.hpp>

View File

@ -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 <nostalgia/core/config.hpp>

View File

@ -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 <ox/fs/fs.hpp>
@ -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<typename T>
constexpr ox::Error modelRead(T *io, GbaTileMapTarget *t) noexcept {
io->template setTypeInfo<GbaTileMapTarget>(GbaTileMapTarget::TypeName, GbaTileMapTarget::Fields);
io->template setTypeInfo<GbaTileMapTarget>();
uint8_t bpp;
int dummy;
oxReturnError(io->field("bpp", &bpp));

View File

@ -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

View File

@ -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

View File

@ -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 <ox/std/types.hpp>

View File

@ -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 <ox/fs/fs.hpp>

View File

@ -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 <ox/std/memops.hpp>

View File

@ -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 <map>

View File

@ -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"

View File

@ -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<Color16> 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

View File

@ -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 <GLFW/glfw3.h>

View File

@ -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 <GLFW/glfw3.h>

View File

@ -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

View File

@ -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 <GLFW/glfw3.h>
@ -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);

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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 <SDL.h>

View File

@ -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

View File

@ -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 <array>

View File

@ -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
<QBuffer>
<QButtonGroup>
<QColor>
<QDebug>
<QDialog>
<QFile>
<QFormLayout>
<QHeaderView>
<QImage>
<QItemDelegate>
<QMap>
<QPainter>
<QPluginLoader>
<QPointer>
<QPushButton>
<QQmlContext>
<QQuickItem>
<QQuickWidget>
<QSettings>
<QSpinBox>
<QSplitter>
<QString>
<QStringList>
<QStyledItemDelegate>
<QTableWidget>
<QToolBar>
<QUndoCommand>
<QUndoStack>
<QVariant>
)
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)

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}
}
}

View File

@ -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

View File

@ -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 <QColor>
@ -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<uint32_t>(c.red()) >> 3;
const auto g = static_cast<uint32_t>(c.green()) >> 3;
const auto b = static_cast<uint32_t>(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<QRgb, bool> 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<core::NostalgiaGraphic> imgToNg(QString argSrc, int argBpp) {
[[nodiscard]]
ox::UniquePtr<core::NostalgiaGraphic> imgToNg(QString argSrc, int argBpp) {
QImage src(argSrc);
if (src.isNull()) {

View File

@ -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 <QString>
#include <ox/std/error.hpp>
#include <ox/std/types.hpp>
@ -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<core::NostalgiaGraphic> imgToNg(QString argInPath, int argBpp = -1);
[[nodiscard]]
ox::UniquePtr<core::NostalgiaGraphic> imgToNg(ox::String argInPath, int argBpp = -1);
}

View File

@ -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 <QBuffer>

View File

@ -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

View File

@ -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<studio::WizardMaker> Module::newWizards(const studio::Context *ctx) {
return {
{
tr("Palette"),
[ctx]() {
QVector<QWizardPage*> pgs;
pgs.push_back(new NewPaletteWizardPage(ctx));
return pgs;
}
},
{
tr("Tile Sheet"),
[ctx]() {
QVector<QWizardPage*> pgs;
pgs.push_back(new NewTilesheetWizardPage(ctx));
return pgs;
}
},
};
}
QVector<studio::WizardMaker> Module::importWizards(const studio::Context *ctx) {
return {
{
tr("Tile Sheet"),
[ctx]() {
QVector<QWizardPage*> pgs;
pgs.push_back(new ImportTilesheetWizardMainPage(ctx));
pgs.push_back(new ImportTilesheetWizardPalettePage(ctx));
return pgs;
}
}
};
}
QVector<studio::EditorMaker> Module::editors(const studio::Context *ctx) {
ox::Vector<studio::EditorMaker> 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);
}
}
};
}
}
}

View File

@ -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 <QPluginLoader>
#include <nostalgia/studio/studio.hpp>
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<studio::WizardMaker> newWizards(const studio::Context *ctx) override;
QVector<studio::WizardMaker> importWizards(const studio::Context *args) override;
QVector<studio::EditorMaker> editors(const studio::Context *ctx) override;
ox::Vector<studio::EditorMaker> editors(core::Context *ctx) override;
};
}

View File

@ -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 <QBuffer>

View File

@ -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

View File

@ -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 <QBuffer>

View File

@ -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

View File

@ -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 <QHeaderView>

View File

@ -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

View File

@ -0,0 +1,55 @@
/*
* Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#pragma once
#include <nostalgia/common/point.hpp>
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});
}

View File

@ -1,7 +0,0 @@
<RCC>
<qresource prefix="/qml">
<file>Pixel.qml</file>
<file>Tile.qml</file>
<file>TileSheetEditor.qml</file>
</qresource>
</RCC>

File diff suppressed because it is too large Load Diff

View File

@ -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 <QButtonGroup>
#include <QStringList>
#include <QStyledItemDelegate>
#include <QUndoStack>
#include <QVariant>
#include <nostalgia/common/bounds.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/glutils/glutils.hpp>
#include <nostalgia/studio/studio.hpp>
#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<typename T>
ox::Error model(T *io, PixelChunk *c) {
constexpr ox::Error model(T *io, PixelChunk *c) noexcept {
io->template setTypeInfo<PixelChunk>();
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<typename T>
friend ox::Error model(T*, TileSheetClipboard*);
protected:
std::vector<int> m_pixels;
ox::Vector<int> 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<int> *tgt, int tgtColumns) const;
void pastePixels(common::Point pt, ox::Vector<int> *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<int> pixelSelected READ pixelSelected NOTIFY pixelSelectedChanged)
Q_PROPERTY(QVector<int> 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<int> m_pixelSelected;
QVector<int> 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<int> &pixelSelected() const;
[[nodiscard]] const QVector<int> &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<int> tileData = {});
QVector<int> deleteTile(int tileIdx);
void setSelectedColor(int index);
void modGteCmd(int val, int mod);
void modPixels(const QHash<int, int> &pixels, int inversion);
void setPixel(int index, int color);
void notifyUpdate();
[[nodiscard]] std::unique_ptr<NostalgiaGraphic> 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<NostalgiaPalette> 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;
};
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <nostalgia/core/consts.hpp>
#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<GLsizei>(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<GLuint>(glGetAttribLocation(m_shader, "vPt1"));
glEnableVertexAttribArray(pt1Attr);
glVertexAttribPointer(pt1Attr, 2, GL_FLOAT, GL_FALSE, VertexVboRowLength * sizeof(float), nullptr);
const auto pt2Attr = static_cast<GLuint>(glGetAttribLocation(m_shader, "vPt2"));
glEnableVertexAttribArray(pt2Attr);
glVertexAttribPointer(pt2Attr, 2, GL_FLOAT, GL_FALSE, VertexVboRowLength * sizeof(float),
reinterpret_cast<void*>(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<float>(pt1.x) * ps.x;
const auto y1 = static_cast<float>(pt1.y) * ps.y;
const auto x2 = static_cast<float>(pt2.x) * ps.x;
const auto y2 = static_cast<float>(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<unsigned>(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};
}
}

View File

@ -0,0 +1,80 @@
/*
* Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#pragma once
#include <imgui.h>
#include <nostalgia/common/point.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/glutils/glutils.hpp>
#include <nostalgia/studio/studio.hpp>
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;
};
}

View File

@ -0,0 +1,108 @@
/*
* Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <nostalgia/core/consts.hpp>
#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<GLsizei>(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<GLuint>(glGetAttribLocation(m_shader, "vPosition"));
glEnableVertexAttribArray(posAttr);
glVertexAttribPointer(posAttr, 2, GL_FLOAT, GL_FALSE, VertexVboRowLength * sizeof(float), nullptr);
const auto colorAttr = static_cast<GLuint>(glGetAttribLocation(m_shader, "vColor"));
glEnableVertexAttribArray(colorAttr);
glVertexAttribPointer(colorAttr, 3, GL_FLOAT, GL_FALSE, VertexVboRowLength * sizeof(float),
reinterpret_cast<void*>(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<float>(pt.x);
const auto fy = static_cast<float>(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<unsigned>(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};
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#pragma once
#include <imgui.h>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/glutils/glutils.hpp>
#include <nostalgia/studio/studio.hpp>
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;
};
}

View File

@ -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"

View File

@ -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

View File

@ -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 <nostalgia/core/gfx.hpp>

View File

@ -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

View File

@ -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 <array>

View File

@ -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 <fstream>

View File

@ -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 <ox/std/bstring.hpp>

View File

@ -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 {};

View File

@ -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 <nostalgia/core/core.hpp>

View File

@ -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 <ox/std/memory.hpp>

View File

@ -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 <nostalgia/core/core.hpp>

View File

@ -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"

View File

@ -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

View File

@ -43,4 +43,4 @@ install(
BUNDLE DESTINATION .
)
add_subdirectory(lib)
add_subdirectory(lib)

View File

@ -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<core::Module>();
// },
//};
[[maybe_unused]] // GCC warns about the existence of this "unused" constexpr list in a header file...
constexpr auto BuiltinModules = {
[] {
return ox::make_unique<core::Module>();
},
};
}

View File

@ -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 <imgui.h>

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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 <ox/std/string.hpp>

View File

@ -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

View File

@ -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

View File

@ -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 <ox/std/defines.hpp>

View File

@ -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"

View File

@ -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

View File

@ -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 <filesystem>

View File

@ -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

View File

@ -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 <algorithm>

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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"

Some files were not shown because too many files have changed in this diff Show More