Merge branch 'main' into ly-as-sdk/LYN-2948
This commit is contained in:
@@ -8,3 +8,8 @@
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(GEM_DEPENDENCIES
|
||||
Gem::Atom_RHI_Metal.Private
|
||||
Gem::Atom_RHI_Null.Private
|
||||
)
|
||||
@@ -8,3 +8,10 @@
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(GEM_DEPENDENCIES
|
||||
Gem::Atom_RHI_Null.Private
|
||||
Gem::Atom_RHI_Null.Builders
|
||||
Gem::Atom_RHI_Metal.Private
|
||||
Gem::Atom_RHI_Metal.Builders
|
||||
)
|
||||
+8
-17
@@ -161,20 +161,6 @@ def run():
|
||||
# Deletion/Undo/Redo test
|
||||
verify_deletion_undo_redo(self.component_name, entity_obj)
|
||||
|
||||
# Area Light Component
|
||||
area_light = "Area Light"
|
||||
ComponentTests(
|
||||
area_light, lambda entity_obj: verify_required_component_addition(
|
||||
entity_obj, ["Capsule Shape"], area_light))
|
||||
|
||||
# Decal Component
|
||||
material_asset_path = os.path.join("AutomatedTesting", "Materials", "basic_grey.material")
|
||||
material_asset = asset.AssetCatalogRequestBus(
|
||||
bus.Broadcast, "GetAssetIdByPath", material_asset_path, math.Uuid(), False)
|
||||
ComponentTests(
|
||||
"Decal (Atom)", lambda entity_obj: verify_set_property(
|
||||
entity_obj, "Controller|Configuration|Material", material_asset))
|
||||
|
||||
# DepthOfField Component
|
||||
camera_entity = hydra.Entity("camera_entity")
|
||||
camera_entity.create_entity(math.Vector3(512.0, 512.0, 34.0), ["Camera"])
|
||||
@@ -185,6 +171,14 @@ def run():
|
||||
lambda entity_obj: verify_set_property(
|
||||
entity_obj, "Controller|Configuration|Camera Entity", camera_entity.id))
|
||||
|
||||
# Decal Component
|
||||
material_asset_path = os.path.join("AutomatedTesting", "Materials", "basic_grey.material")
|
||||
material_asset = asset.AssetCatalogRequestBus(
|
||||
bus.Broadcast, "GetAssetIdByPath", material_asset_path, math.Uuid(), False)
|
||||
ComponentTests(
|
||||
"Decal (Atom)", lambda entity_obj: verify_set_property(
|
||||
entity_obj, "Controller|Configuration|Material", material_asset))
|
||||
|
||||
# Directional Light Component
|
||||
ComponentTests(
|
||||
"Directional Light",
|
||||
@@ -213,9 +207,6 @@ def run():
|
||||
# Physical Sky Component
|
||||
ComponentTests("Physical Sky")
|
||||
|
||||
# Point Light Component
|
||||
ComponentTests("Point Light")
|
||||
|
||||
# PostFX Layer Component
|
||||
ComponentTests("PostFX Layer")
|
||||
|
||||
|
||||
@@ -27,194 +27,6 @@ TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "atom_hydra_scripts")
|
||||
@pytest.mark.parametrize("level", ["auto_test"])
|
||||
class TestAtomEditorComponentsMain(object):
|
||||
|
||||
@pytest.mark.test_case_id(
|
||||
"C32078117", # Area Light
|
||||
"C32078130", # Display Mapper
|
||||
"C32078129", # Light
|
||||
"C32078131", # Radius Weight Modifier
|
||||
"C32078127", # PostFX Layer
|
||||
"C32078126", # Point Light
|
||||
"C32078125", # Physical Sky
|
||||
"C32078115", # Global Skylight (IBL)
|
||||
"C32078121", # Exposure Control
|
||||
"C32078120", # Directional Light
|
||||
"C32078119", # DepthOfField
|
||||
"C32078118") # Decal
|
||||
def test_AtomEditorComponents_AddedToEntity(self, request, editor, level, workspace, project, launcher_platform):
|
||||
cfg_args = [level]
|
||||
|
||||
expected_lines = [
|
||||
# Area Light Component
|
||||
"Area Light Entity successfully created",
|
||||
"Area Light_test: Component added to the entity: True",
|
||||
"Area Light_test: Component removed after UNDO: True",
|
||||
"Area Light_test: Component added after REDO: True",
|
||||
"Area Light_test: Entered game mode: True",
|
||||
"Area Light_test: Entity enabled after adding required components: True",
|
||||
"Area Light_test: Entity is hidden: True",
|
||||
"Area Light_test: Entity is shown: True",
|
||||
"Area Light_test: Entity deleted: True",
|
||||
"Area Light_test: UNDO entity deletion works: True",
|
||||
"Area Light_test: REDO entity deletion works: True",
|
||||
# Decal Component
|
||||
"Decal (Atom) Entity successfully created",
|
||||
"Decal (Atom)_test: Component added to the entity: True",
|
||||
"Decal (Atom)_test: Component removed after UNDO: True",
|
||||
"Decal (Atom)_test: Component added after REDO: True",
|
||||
"Decal (Atom)_test: Entered game mode: True",
|
||||
"Decal (Atom)_test: Exit game mode: True",
|
||||
"Decal (Atom) Controller|Configuration|Material: SUCCESS",
|
||||
"Decal (Atom)_test: Entity is hidden: True",
|
||||
"Decal (Atom)_test: Entity is shown: True",
|
||||
"Decal (Atom)_test: Entity deleted: True",
|
||||
"Decal (Atom)_test: UNDO entity deletion works: True",
|
||||
"Decal (Atom)_test: REDO entity deletion works: True",
|
||||
# DepthOfField Component
|
||||
"DepthOfField Entity successfully created",
|
||||
"DepthOfField_test: Component added to the entity: True",
|
||||
"DepthOfField_test: Component removed after UNDO: True",
|
||||
"DepthOfField_test: Component added after REDO: True",
|
||||
"DepthOfField_test: Entered game mode: True",
|
||||
"DepthOfField_test: Exit game mode: True",
|
||||
"DepthOfField_test: Entity disabled initially: True",
|
||||
"DepthOfField_test: Entity enabled after adding required components: True",
|
||||
"DepthOfField Controller|Configuration|Camera Entity: SUCCESS",
|
||||
"DepthOfField_test: Entity is hidden: True",
|
||||
"DepthOfField_test: Entity is shown: True",
|
||||
"DepthOfField_test: Entity deleted: True",
|
||||
"DepthOfField_test: UNDO entity deletion works: True",
|
||||
"DepthOfField_test: REDO entity deletion works: True",
|
||||
# Directional Light Component
|
||||
"Directional Light Entity successfully created",
|
||||
"Directional Light_test: Component added to the entity: True",
|
||||
"Directional Light_test: Component removed after UNDO: True",
|
||||
"Directional Light_test: Component added after REDO: True",
|
||||
"Directional Light_test: Entered game mode: True",
|
||||
"Directional Light_test: Exit game mode: True",
|
||||
"Directional Light Controller|Configuration|Shadow|Camera: SUCCESS",
|
||||
"Directional Light_test: Entity is hidden: True",
|
||||
"Directional Light_test: Entity is shown: True",
|
||||
"Directional Light_test: Entity deleted: True",
|
||||
"Directional Light_test: UNDO entity deletion works: True",
|
||||
"Directional Light_test: REDO entity deletion works: True",
|
||||
# Exposure Control Component
|
||||
"Exposure Control Entity successfully created",
|
||||
"Exposure Control_test: Component added to the entity: True",
|
||||
"Exposure Control_test: Component removed after UNDO: True",
|
||||
"Exposure Control_test: Component added after REDO: True",
|
||||
"Exposure Control_test: Entered game mode: True",
|
||||
"Exposure Control_test: Exit game mode: True",
|
||||
"Exposure Control_test: Entity disabled initially: True",
|
||||
"Exposure Control_test: Entity enabled after adding required components: True",
|
||||
"Exposure Control_test: Entity is hidden: True",
|
||||
"Exposure Control_test: Entity is shown: True",
|
||||
"Exposure Control_test: Entity deleted: True",
|
||||
"Exposure Control_test: UNDO entity deletion works: True",
|
||||
"Exposure Control_test: REDO entity deletion works: True",
|
||||
# Global Skylight (IBL) Component
|
||||
"Global Skylight (IBL) Entity successfully created",
|
||||
"Global Skylight (IBL)_test: Component added to the entity: True",
|
||||
"Global Skylight (IBL)_test: Component removed after UNDO: True",
|
||||
"Global Skylight (IBL)_test: Component added after REDO: True",
|
||||
"Global Skylight (IBL)_test: Entered game mode: True",
|
||||
"Global Skylight (IBL)_test: Exit game mode: True",
|
||||
"Global Skylight (IBL) Controller|Configuration|Diffuse Image: SUCCESS",
|
||||
"Global Skylight (IBL) Controller|Configuration|Specular Image: SUCCESS",
|
||||
"Global Skylight (IBL)_test: Entity is hidden: True",
|
||||
"Global Skylight (IBL)_test: Entity is shown: True",
|
||||
"Global Skylight (IBL)_test: Entity deleted: True",
|
||||
"Global Skylight (IBL)_test: UNDO entity deletion works: True",
|
||||
"Global Skylight (IBL)_test: REDO entity deletion works: True",
|
||||
# Physical Sky Component
|
||||
"Physical Sky Entity successfully created",
|
||||
"Physical Sky component was added to entity",
|
||||
"Entity has a Physical Sky component",
|
||||
"Physical Sky_test: Component added to the entity: True",
|
||||
"Physical Sky_test: Component removed after UNDO: True",
|
||||
"Physical Sky_test: Component added after REDO: True",
|
||||
"Physical Sky_test: Entered game mode: True",
|
||||
"Physical Sky_test: Exit game mode: True",
|
||||
"Physical Sky_test: Entity is hidden: True",
|
||||
"Physical Sky_test: Entity is shown: True",
|
||||
"Physical Sky_test: Entity deleted: True",
|
||||
"Physical Sky_test: UNDO entity deletion works: True",
|
||||
"Physical Sky_test: REDO entity deletion works: True",
|
||||
# Point Light Component
|
||||
"Point Light Entity successfully created",
|
||||
"Point Light_test: Component added to the entity: True",
|
||||
"Point Light_test: Component removed after UNDO: True",
|
||||
"Point Light_test: Component added after REDO: True",
|
||||
"Point Light_test: Entered game mode: True",
|
||||
"Point Light_test: Exit game mode: True",
|
||||
"Point Light_test: Entity is hidden: True",
|
||||
"Point Light_test: Entity is shown: True",
|
||||
"Point Light_test: Entity deleted: True",
|
||||
"Point Light_test: UNDO entity deletion works: True",
|
||||
"Point Light_test: REDO entity deletion works: True",
|
||||
# PostFX Layer Component
|
||||
"PostFX Layer Entity successfully created",
|
||||
"PostFX Layer_test: Component added to the entity: True",
|
||||
"PostFX Layer_test: Component removed after UNDO: True",
|
||||
"PostFX Layer_test: Component added after REDO: True",
|
||||
"PostFX Layer_test: Entered game mode: True",
|
||||
"PostFX Layer_test: Exit game mode: True",
|
||||
"PostFX Layer_test: Entity is hidden: True",
|
||||
"PostFX Layer_test: Entity is shown: True",
|
||||
"PostFX Layer_test: Entity deleted: True",
|
||||
"PostFX Layer_test: UNDO entity deletion works: True",
|
||||
"PostFX Layer_test: REDO entity deletion works: True",
|
||||
# Radius Weight Modifier Component
|
||||
"Radius Weight Modifier Entity successfully created",
|
||||
"Radius Weight Modifier_test: Component added to the entity: True",
|
||||
"Radius Weight Modifier_test: Component removed after UNDO: True",
|
||||
"Radius Weight Modifier_test: Component added after REDO: True",
|
||||
"Radius Weight Modifier_test: Entered game mode: True",
|
||||
"Radius Weight Modifier_test: Exit game mode: True",
|
||||
"Radius Weight Modifier_test: Entity is hidden: True",
|
||||
"Radius Weight Modifier_test: Entity is shown: True",
|
||||
"Radius Weight Modifier_test: Entity deleted: True",
|
||||
"Radius Weight Modifier_test: UNDO entity deletion works: True",
|
||||
"Radius Weight Modifier_test: REDO entity deletion works: True",
|
||||
# Light Component
|
||||
"Light Entity successfully created",
|
||||
"Light_test: Component added to the entity: True",
|
||||
"Light_test: Component removed after UNDO: True",
|
||||
"Light_test: Component added after REDO: True",
|
||||
"Light_test: Entered game mode: True",
|
||||
"Light_test: Exit game mode: True",
|
||||
"Light_test: Entity is hidden: True",
|
||||
"Light_test: Entity is shown: True",
|
||||
"Light_test: Entity deleted: True",
|
||||
"Light_test: UNDO entity deletion works: True",
|
||||
"Light_test: REDO entity deletion works: True",
|
||||
# Display Mapper Component
|
||||
"Display Mapper Entity successfully created",
|
||||
"Display Mapper_test: Component added to the entity: True",
|
||||
"Display Mapper_test: Component removed after UNDO: True",
|
||||
"Display Mapper_test: Component added after REDO: True",
|
||||
"Display Mapper_test: Entered game mode: True",
|
||||
"Display Mapper_test: Exit game mode: True",
|
||||
"Display Mapper_test: Entity is hidden: True",
|
||||
"Display Mapper_test: Entity is shown: True",
|
||||
"Display Mapper_test: Entity deleted: True",
|
||||
"Display Mapper_test: UNDO entity deletion works: True",
|
||||
"Display Mapper_test: REDO entity deletion works: True",
|
||||
]
|
||||
|
||||
unexpected_lines = [
|
||||
"failed to open",
|
||||
"Traceback (most recent call last):",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
TEST_DIRECTORY,
|
||||
editor,
|
||||
"hydra_AtomEditorComponents_AddedToEntity.py",
|
||||
timeout=EDITOR_TIMEOUT,
|
||||
expected_lines=expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
halt_on_unexpected=True,
|
||||
null_renderer=True,
|
||||
cfg_args=cfg_args,
|
||||
)
|
||||
# It requires at least one test
|
||||
def test_Dummy(self, request, editor, level, workspace, project, launcher_platform):
|
||||
pass
|
||||
|
||||
@@ -19,6 +19,170 @@ import pytest
|
||||
@pytest.mark.parametrize("level", ["auto_test"])
|
||||
class TestAtomEditorComponentsSandbox(object):
|
||||
|
||||
# It requires at least one test
|
||||
def test_Dummy(self, request, editor, level, workspace, project, launcher_platform):
|
||||
pass
|
||||
@pytest.mark.test_case_id(
|
||||
"C32078117", # Area Light
|
||||
"C32078130", # Display Mapper
|
||||
"C32078129", # Light
|
||||
"C32078131", # Radius Weight Modifier
|
||||
"C32078127", # PostFX Layer
|
||||
"C32078126", # Point Light
|
||||
"C32078125", # Physical Sky
|
||||
"C32078115", # Global Skylight (IBL)
|
||||
"C32078121", # Exposure Control
|
||||
"C32078120", # Directional Light
|
||||
"C32078119", # DepthOfField
|
||||
"C32078118") # Decal
|
||||
def test_AtomEditorComponents_AddedToEntity(self, request, editor, level, workspace, project, launcher_platform):
|
||||
cfg_args = [level]
|
||||
|
||||
expected_lines = [
|
||||
# Decal Component
|
||||
"Decal (Atom) Entity successfully created",
|
||||
"Decal (Atom)_test: Component added to the entity: True",
|
||||
"Decal (Atom)_test: Component removed after UNDO: True",
|
||||
"Decal (Atom)_test: Component added after REDO: True",
|
||||
"Decal (Atom)_test: Entered game mode: True",
|
||||
"Decal (Atom)_test: Exit game mode: True",
|
||||
"Decal (Atom) Controller|Configuration|Material: SUCCESS",
|
||||
"Decal (Atom)_test: Entity is hidden: True",
|
||||
"Decal (Atom)_test: Entity is shown: True",
|
||||
"Decal (Atom)_test: Entity deleted: True",
|
||||
"Decal (Atom)_test: UNDO entity deletion works: True",
|
||||
"Decal (Atom)_test: REDO entity deletion works: True",
|
||||
# DepthOfField Component
|
||||
"DepthOfField Entity successfully created",
|
||||
"DepthOfField_test: Component added to the entity: True",
|
||||
"DepthOfField_test: Component removed after UNDO: True",
|
||||
"DepthOfField_test: Component added after REDO: True",
|
||||
"DepthOfField_test: Entered game mode: True",
|
||||
"DepthOfField_test: Exit game mode: True",
|
||||
"DepthOfField_test: Entity disabled initially: True",
|
||||
"DepthOfField_test: Entity enabled after adding required components: True",
|
||||
"DepthOfField Controller|Configuration|Camera Entity: SUCCESS",
|
||||
"DepthOfField_test: Entity is hidden: True",
|
||||
"DepthOfField_test: Entity is shown: True",
|
||||
"DepthOfField_test: Entity deleted: True",
|
||||
"DepthOfField_test: UNDO entity deletion works: True",
|
||||
"DepthOfField_test: REDO entity deletion works: True",
|
||||
# Directional Light Component
|
||||
"Directional Light Entity successfully created",
|
||||
"Directional Light_test: Component added to the entity: True",
|
||||
"Directional Light_test: Component removed after UNDO: True",
|
||||
"Directional Light_test: Component added after REDO: True",
|
||||
"Directional Light_test: Entered game mode: True",
|
||||
"Directional Light_test: Exit game mode: True",
|
||||
"Directional Light Controller|Configuration|Shadow|Camera: SUCCESS",
|
||||
"Directional Light_test: Entity is hidden: True",
|
||||
"Directional Light_test: Entity is shown: True",
|
||||
"Directional Light_test: Entity deleted: True",
|
||||
"Directional Light_test: UNDO entity deletion works: True",
|
||||
"Directional Light_test: REDO entity deletion works: True",
|
||||
# Exposure Control Component
|
||||
"Exposure Control Entity successfully created",
|
||||
"Exposure Control_test: Component added to the entity: True",
|
||||
"Exposure Control_test: Component removed after UNDO: True",
|
||||
"Exposure Control_test: Component added after REDO: True",
|
||||
"Exposure Control_test: Entered game mode: True",
|
||||
"Exposure Control_test: Exit game mode: True",
|
||||
"Exposure Control_test: Entity disabled initially: True",
|
||||
"Exposure Control_test: Entity enabled after adding required components: True",
|
||||
"Exposure Control_test: Entity is hidden: True",
|
||||
"Exposure Control_test: Entity is shown: True",
|
||||
"Exposure Control_test: Entity deleted: True",
|
||||
"Exposure Control_test: UNDO entity deletion works: True",
|
||||
"Exposure Control_test: REDO entity deletion works: True",
|
||||
# Global Skylight (IBL) Component
|
||||
"Global Skylight (IBL) Entity successfully created",
|
||||
"Global Skylight (IBL)_test: Component added to the entity: True",
|
||||
"Global Skylight (IBL)_test: Component removed after UNDO: True",
|
||||
"Global Skylight (IBL)_test: Component added after REDO: True",
|
||||
"Global Skylight (IBL)_test: Entered game mode: True",
|
||||
"Global Skylight (IBL)_test: Exit game mode: True",
|
||||
"Global Skylight (IBL) Controller|Configuration|Diffuse Image: SUCCESS",
|
||||
"Global Skylight (IBL) Controller|Configuration|Specular Image: SUCCESS",
|
||||
"Global Skylight (IBL)_test: Entity is hidden: True",
|
||||
"Global Skylight (IBL)_test: Entity is shown: True",
|
||||
"Global Skylight (IBL)_test: Entity deleted: True",
|
||||
"Global Skylight (IBL)_test: UNDO entity deletion works: True",
|
||||
"Global Skylight (IBL)_test: REDO entity deletion works: True",
|
||||
# Physical Sky Component
|
||||
"Physical Sky Entity successfully created",
|
||||
"Physical Sky component was added to entity",
|
||||
"Entity has a Physical Sky component",
|
||||
"Physical Sky_test: Component added to the entity: True",
|
||||
"Physical Sky_test: Component removed after UNDO: True",
|
||||
"Physical Sky_test: Component added after REDO: True",
|
||||
"Physical Sky_test: Entered game mode: True",
|
||||
"Physical Sky_test: Exit game mode: True",
|
||||
"Physical Sky_test: Entity is hidden: True",
|
||||
"Physical Sky_test: Entity is shown: True",
|
||||
"Physical Sky_test: Entity deleted: True",
|
||||
"Physical Sky_test: UNDO entity deletion works: True",
|
||||
"Physical Sky_test: REDO entity deletion works: True",
|
||||
# PostFX Layer Component
|
||||
"PostFX Layer Entity successfully created",
|
||||
"PostFX Layer_test: Component added to the entity: True",
|
||||
"PostFX Layer_test: Component removed after UNDO: True",
|
||||
"PostFX Layer_test: Component added after REDO: True",
|
||||
"PostFX Layer_test: Entered game mode: True",
|
||||
"PostFX Layer_test: Exit game mode: True",
|
||||
"PostFX Layer_test: Entity is hidden: True",
|
||||
"PostFX Layer_test: Entity is shown: True",
|
||||
"PostFX Layer_test: Entity deleted: True",
|
||||
"PostFX Layer_test: UNDO entity deletion works: True",
|
||||
"PostFX Layer_test: REDO entity deletion works: True",
|
||||
# Radius Weight Modifier Component
|
||||
"Radius Weight Modifier Entity successfully created",
|
||||
"Radius Weight Modifier_test: Component added to the entity: True",
|
||||
"Radius Weight Modifier_test: Component removed after UNDO: True",
|
||||
"Radius Weight Modifier_test: Component added after REDO: True",
|
||||
"Radius Weight Modifier_test: Entered game mode: True",
|
||||
"Radius Weight Modifier_test: Exit game mode: True",
|
||||
"Radius Weight Modifier_test: Entity is hidden: True",
|
||||
"Radius Weight Modifier_test: Entity is shown: True",
|
||||
"Radius Weight Modifier_test: Entity deleted: True",
|
||||
"Radius Weight Modifier_test: UNDO entity deletion works: True",
|
||||
"Radius Weight Modifier_test: REDO entity deletion works: True",
|
||||
# Light Component
|
||||
"Light Entity successfully created",
|
||||
"Light_test: Component added to the entity: True",
|
||||
"Light_test: Component removed after UNDO: True",
|
||||
"Light_test: Component added after REDO: True",
|
||||
"Light_test: Entered game mode: True",
|
||||
"Light_test: Exit game mode: True",
|
||||
"Light_test: Entity is hidden: True",
|
||||
"Light_test: Entity is shown: True",
|
||||
"Light_test: Entity deleted: True",
|
||||
"Light_test: UNDO entity deletion works: True",
|
||||
"Light_test: REDO entity deletion works: True",
|
||||
# Display Mapper Component
|
||||
"Display Mapper Entity successfully created",
|
||||
"Display Mapper_test: Component added to the entity: True",
|
||||
"Display Mapper_test: Component removed after UNDO: True",
|
||||
"Display Mapper_test: Component added after REDO: True",
|
||||
"Display Mapper_test: Entered game mode: True",
|
||||
"Display Mapper_test: Exit game mode: True",
|
||||
"Display Mapper_test: Entity is hidden: True",
|
||||
"Display Mapper_test: Entity is shown: True",
|
||||
"Display Mapper_test: Entity deleted: True",
|
||||
"Display Mapper_test: UNDO entity deletion works: True",
|
||||
"Display Mapper_test: REDO entity deletion works: True",
|
||||
]
|
||||
|
||||
unexpected_lines = [
|
||||
"failed to open",
|
||||
"Traceback (most recent call last):",
|
||||
]
|
||||
|
||||
hydra.launch_and_validate_results(
|
||||
request,
|
||||
TEST_DIRECTORY,
|
||||
editor,
|
||||
"hydra_AtomEditorComponents_AddedToEntity.py",
|
||||
timeout=EDITOR_TIMEOUT,
|
||||
expected_lines=expected_lines,
|
||||
unexpected_lines=unexpected_lines,
|
||||
halt_on_unexpected=True,
|
||||
null_renderer=True,
|
||||
cfg_args=cfg_args,
|
||||
)
|
||||
|
||||
@@ -10,5 +10,4 @@
|
||||
#
|
||||
|
||||
add_subdirectory(CryCommon)
|
||||
add_subdirectory(CryFont)
|
||||
add_subdirectory(CrySystem)
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
|
||||
#include <CryCommon/ISystem.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
/*!
|
||||
* Signal LY to create an ICryFont
|
||||
*/
|
||||
class CryFontCreationRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
using MutexType = AZStd::recursive_mutex;
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
|
||||
virtual bool CreateCryFont([[maybe_unused]] SSystemGlobalEnvironment& env, [[maybe_unused]] const SSystemInitParams& initParams) {return false;} //! return false to fall back to default CryFont initialization
|
||||
};
|
||||
using CryFontCreationRequestBus = AZ::EBus<CryFontCreationRequests>;
|
||||
|
||||
}
|
||||
@@ -1,845 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : CCryFont class.
|
||||
|
||||
|
||||
#include "CryFont_precompiled.h"
|
||||
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#include "CryFont.h"
|
||||
#include "CryPath.h"
|
||||
#include "FFont.h"
|
||||
#include "FontTexture.h"
|
||||
#include "FontRenderer.h"
|
||||
#include "ILocalizationManager.h"
|
||||
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzFramework/Archive/IArchive.h>
|
||||
|
||||
// Static member definitions
|
||||
const Vec2i CCryFont::defaultGlyphSize = Vec2i(ICryFont::defaultGlyphSizeX, ICryFont::defaultGlyphSizeY);
|
||||
|
||||
#if !defined(_RELEASE)
|
||||
static void DumpFontTexture(IConsoleCmdArgs* pArgs)
|
||||
{
|
||||
if (pArgs->GetArgCount() != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const char* pFontName = pArgs->GetArg(1);
|
||||
|
||||
if (pFontName && *pFontName && *pFontName != '0')
|
||||
{
|
||||
string fontFile("@devroot@/");
|
||||
fontFile += pFontName;
|
||||
fontFile += ".bmp";
|
||||
|
||||
CFFont* pFont = (CFFont*) gEnv->pCryFont->GetFont(pFontName);
|
||||
if (pFont)
|
||||
{
|
||||
pFont->GetFontTexture()->WriteToFile(fontFile.c_str());
|
||||
gEnv->pLog->LogWithType(IMiniLog::eInputResponse, "Dumped \"%s\" texture to \"%s\"!", pFontName, fontFile.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DumpFontNames([[maybe_unused]] IConsoleCmdArgs* pArgs)
|
||||
{
|
||||
string names = gEnv->pCryFont->GetLoadedFontNames();
|
||||
gEnv->pLog->LogWithType(IMiniLog::eInputResponse, "Currently loaded fonts: %s", names.c_str());
|
||||
}
|
||||
|
||||
static void ReloadFonts([[maybe_unused]] IConsoleCmdArgs* pArgs)
|
||||
{
|
||||
gEnv->pCryFont->ReloadAllFonts();
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Stores paths to styled font assets for a given set of languages
|
||||
//! This struct stores the XML data contained within the <font> tag of
|
||||
//! an enclosing <fontfamily> definition:
|
||||
//!
|
||||
//! <fontfamily name="FontFamilyName">
|
||||
//! <font lang="Language1, Language2">
|
||||
//! <file path="regular.font" />
|
||||
//! <file path="bold.font" tags="b" />
|
||||
//! <file path="italic.font" tags="i" />
|
||||
//! <file path="bolditalic.font" tags="b,i" />
|
||||
//! </font>
|
||||
//! </fontfamily>
|
||||
struct FontTagXml
|
||||
{
|
||||
//! \return True if all font asset paths are non-empty, false otherwise
|
||||
bool IsValid() const
|
||||
{
|
||||
// Note that "lang" can be empty
|
||||
return !m_fontFilename.empty()
|
||||
&& !m_boldFontFilename.empty()
|
||||
&& !m_italicFontFilename.empty()
|
||||
&& !m_boldItalicFontFilename.empty();
|
||||
}
|
||||
|
||||
string m_lang; //!< Stores a comma-separated list of languages this collection of fonts applies to.
|
||||
//!< If this is an empty string, it implies that these set of fonts will be applied
|
||||
//!< by default (when a language is being used but no fonts in the font family are
|
||||
//!< mapped to that language).
|
||||
|
||||
string m_fontFilename; //!< Font used when no styling is applied.
|
||||
string m_boldFontFilename; //!< Bold-styled font
|
||||
string m_italicFontFilename; //!< Italic-styled font
|
||||
string m_boldItalicFontFilename; //!< Bold-italic-styled font
|
||||
};
|
||||
|
||||
//! Stores parsed font family XML data.
|
||||
//! This struct contains the name of the font family and a list of font
|
||||
//! file XML data for all the language-specific mappings of this
|
||||
//! font family.
|
||||
//!
|
||||
//! Example XML:
|
||||
//!
|
||||
//! <fontfamily name="FontFamilyName">
|
||||
//! <font>
|
||||
//! <file path="regular.font" />
|
||||
//! <file path="bold.font" tags="b" />
|
||||
//! <file path="italic.font" tags="i" />
|
||||
//! <file path="bolditalic.font" tags="b,i" />
|
||||
//! </font>
|
||||
//! <font lang="korean">
|
||||
//! <file path="../korean/korean-regular.font" />
|
||||
//! <file path="../korean/korean-italic.font" tags="b" />
|
||||
//! <file path="../korean/korean-bold.font" tags="i" />
|
||||
//! <file path="../korean/korean-bolditalic.font" tags="b,i" />
|
||||
//! </font>
|
||||
//! <font lang="chinesesimplified">
|
||||
//! <file path="../chinesesimplified/chinesesimplified-regular.font" />
|
||||
//! <file path="../chinesesimplified/chinesesimplified-bold.font" tags="b" />
|
||||
//! <file path="../chinesesimplified/chinesesimplified-italic.font" tags="i" />
|
||||
//! <file path="../chinesesimplified/chinesesimplified-bolditalic.font" tags="b,i" />
|
||||
//! </font>
|
||||
//! </fontfamily>
|
||||
struct FontFamilyTagXml
|
||||
{
|
||||
//! Returns true if all font file fields were parsed, false otherwise.
|
||||
bool IsValid() const
|
||||
{
|
||||
for (const FontTagXml& fontTagXml : m_fontTagsXml)
|
||||
{
|
||||
if (!fontTagXml.IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Every font family must have a name
|
||||
return !m_fontFamilyName.empty();
|
||||
}
|
||||
|
||||
string m_fontFamilyName; //!< Value of the "name" font-family tag attribute
|
||||
AZStd::list<FontTagXml> m_fontTagsXml; //!< List of child <font> tag data.
|
||||
};
|
||||
|
||||
//! Returns true if the XML tree was traversed successfully, false otherwise.
|
||||
//!
|
||||
//! Note that, if this function returns true, it simply means that there were
|
||||
//! no unexpected structure issues with the given XML tree, it doesn't
|
||||
//! necessarily mean that all the required fields were parsed.
|
||||
bool ParseFontFamilyXml(const XmlNodeRef& node, FontFamilyTagXml& xmlData)
|
||||
{
|
||||
if (!node)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// <fontfamily>
|
||||
if (AZStd::string(node->getTag()) == "fontfamily")
|
||||
{
|
||||
const int numAttributes = node->getNumAttributes();
|
||||
|
||||
if (numAttributes <= 0)
|
||||
{
|
||||
// Expecting at least one attribute
|
||||
return false;
|
||||
}
|
||||
|
||||
string name;
|
||||
|
||||
for (int i = 0, count = node->getNumAttributes(); i < count; ++i)
|
||||
{
|
||||
const char* key = "";
|
||||
const char* value = "";
|
||||
if (node->getAttributeByIndex(i, &key, &value))
|
||||
{
|
||||
if (string(key) == "name")
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unexpected font tag attribute
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
name.Trim();
|
||||
if (!name.empty())
|
||||
{
|
||||
xmlData.m_fontFamilyName = name;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Font family must have a name
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// <font>
|
||||
if (AZStd::string(node->getTag()) == "font")
|
||||
{
|
||||
xmlData.m_fontTagsXml.push_back(FontTagXml());
|
||||
|
||||
string lang;
|
||||
for (int i = 0, count = node->getNumAttributes(); i < count; ++i)
|
||||
{
|
||||
const char* key = "";
|
||||
const char* value = "";
|
||||
if (node->getAttributeByIndex(i, &key, &value))
|
||||
{
|
||||
if (string(key) == "lang")
|
||||
{
|
||||
lang = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unexpected font tag attribute
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lang.Trim();
|
||||
if (!lang.empty())
|
||||
{
|
||||
xmlData.m_fontTagsXml.back().m_lang = lang;
|
||||
}
|
||||
}
|
||||
|
||||
// <file>
|
||||
else if (AZStd::string(node->getTag()) == "file")
|
||||
{
|
||||
const int numAttributes = node->getNumAttributes();
|
||||
|
||||
if (numAttributes <= 0)
|
||||
{
|
||||
// Expecting at least one attribute
|
||||
return false;
|
||||
}
|
||||
|
||||
string path;
|
||||
string tags;
|
||||
|
||||
for (int i = 0, count = node->getNumAttributes(); i < count; ++i)
|
||||
{
|
||||
const char* key = "";
|
||||
const char* value = "";
|
||||
if (node->getAttributeByIndex(i, &key, &value))
|
||||
{
|
||||
if (string(key) == "path")
|
||||
{
|
||||
path = value;
|
||||
}
|
||||
else if (string(key) == "tags")
|
||||
{
|
||||
tags = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unexpected font tag attribute
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tags.Trim();
|
||||
if (tags.empty())
|
||||
{
|
||||
xmlData.m_fontTagsXml.back().m_fontFilename = path;
|
||||
}
|
||||
else if (tags == "b")
|
||||
{
|
||||
xmlData.m_fontTagsXml.back().m_boldFontFilename = path;
|
||||
}
|
||||
else if (tags == "i")
|
||||
{
|
||||
xmlData.m_fontTagsXml.back().m_italicFontFilename = path;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We'll just assume any other tag indicates bold italic
|
||||
xmlData.m_fontTagsXml.back().m_boldItalicFontFilename = path;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0, count = node->getChildCount(); i < count; ++i)
|
||||
{
|
||||
XmlNodeRef child = node->getChild(i);
|
||||
if (!ParseFontFamilyXml(child, xmlData))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Only attempt XML file load if file exists.
|
||||
//! There are use-cases where the XML path is not fully known (such as
|
||||
//! when referencing font family names from font family XML files), and
|
||||
//! attempting to load the XML files directly via ISystem() methods can
|
||||
//! produce a lot of warning noise.
|
||||
XmlNodeRef SafeLoadXmlFromFile(const string& xmlPath)
|
||||
{
|
||||
if (gEnv->pCryPak->IsFileExist(xmlPath.c_str()))
|
||||
{
|
||||
return GetISystem()->LoadXmlFromFile(xmlPath.c_str());
|
||||
}
|
||||
|
||||
return XmlNodeRef();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CCryFont::CCryFont(ISystem* pSystem)
|
||||
: m_pSystem(pSystem)
|
||||
, m_fonts()
|
||||
, m_rndPropIsRGBA(false)
|
||||
, m_rndPropHalfTexelOffset(0.5f)
|
||||
{
|
||||
assert(m_pSystem);
|
||||
|
||||
CryLogAlways("Using FreeType %d.%d.%d", FREETYPE_MAJOR, FREETYPE_MINOR, FREETYPE_PATCH);
|
||||
|
||||
// Persist fonts for application lifetime to prevent unnecessary work
|
||||
REGISTER_CVAR(r_persistFontFamilies, r_persistFontFamilies, VF_NULL, "Persist loaded font families for lifetime of application.");
|
||||
|
||||
#if !defined(_RELEASE)
|
||||
REGISTER_COMMAND("r_DumpFontTexture", DumpFontTexture, 0,
|
||||
"Dumps the specified font's texture to a bitmap file\n"
|
||||
"Use r_DumpFontTexture to get the loaded font names\n"
|
||||
"Usage: r_DumpFontTexture <fontname>");
|
||||
REGISTER_COMMAND("r_DumpFontNames", DumpFontNames, 0,
|
||||
"Logs a list of fonts currently loaded");
|
||||
REGISTER_COMMAND("r_ReloadFonts", ReloadFonts, VF_NULL,
|
||||
"Reload all fonts");
|
||||
#endif
|
||||
}
|
||||
|
||||
CCryFont::~CCryFont()
|
||||
{
|
||||
// Persist fonts for application lifetime to prevent unnecessary work
|
||||
m_persistedFontFamilies.clear();
|
||||
|
||||
for (FontMapItor it = m_fonts.begin(), itEnd = m_fonts.end(); it != itEnd; )
|
||||
{
|
||||
CFFont* pFont = it->second;
|
||||
++it; // iterate as Release() below will remove font from the map
|
||||
SAFE_RELEASE(pFont);
|
||||
}
|
||||
}
|
||||
|
||||
void CCryFont::Release()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
IFFont* CCryFont::NewFont(const char* pFontName)
|
||||
{
|
||||
string name = pFontName;
|
||||
name.MakeLower();
|
||||
|
||||
FontMapItor it = m_fonts.find(CONST_TEMP_STRING(name.c_str()));
|
||||
if (it != m_fonts.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
CFFont* pFont = new CFFont(m_pSystem, this, name.c_str());
|
||||
m_fonts.insert(FontMapItor::value_type(name, pFont));
|
||||
return pFont;
|
||||
}
|
||||
|
||||
IFFont* CCryFont::GetFont(const char* pFontName) const
|
||||
{
|
||||
FontMapConstItor it = m_fonts.find(CONST_TEMP_STRING(string(pFontName).MakeLower()));
|
||||
return it != m_fonts.end() ? it->second : 0;
|
||||
}
|
||||
|
||||
FontFamilyPtr CCryFont::LoadFontFamily(const char* pFontFamilyName)
|
||||
{
|
||||
FontFamilyPtr fontFamily(nullptr);
|
||||
string fontFamilyPath;
|
||||
string fontFamilyFullPath;
|
||||
|
||||
XmlNodeRef root = LoadFontFamilyXml(pFontFamilyName, fontFamilyPath, fontFamilyFullPath);
|
||||
|
||||
if (root)
|
||||
{
|
||||
FontFamilyTagXml xmlData;
|
||||
const bool parseSuccess = ParseFontFamilyXml(root, xmlData);
|
||||
if (parseSuccess && xmlData.IsValid())
|
||||
{
|
||||
const char* currentLanguage = gEnv->pSystem->GetLocalizationManager()->GetLanguage();
|
||||
FontTagXml* defaultFont = nullptr;
|
||||
FontTagXml* langSpecificFont = nullptr;
|
||||
|
||||
// Note that we don't break out of this for-loop early because we
|
||||
// want to find both the default font family and the
|
||||
// language-specific font family. We prefer the lang-specific
|
||||
// family but will fall back on the default if it doesn't exist.
|
||||
for (FontTagXml& fontTagXml : xmlData.m_fontTagsXml)
|
||||
{
|
||||
if (fontTagXml.m_lang.empty())
|
||||
{
|
||||
defaultFont = &fontTagXml;
|
||||
}
|
||||
else
|
||||
{
|
||||
int searchPos = 0;
|
||||
string langToken;
|
||||
|
||||
// "lang" font-tag attribute could be comma-separated
|
||||
while (!(langToken = fontTagXml.m_lang.Tokenize(",", searchPos)).empty())
|
||||
{
|
||||
if (langToken.Trim() == currentLanguage)
|
||||
{
|
||||
langSpecificFont = &fontTagXml;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (langSpecificFont || defaultFont)
|
||||
{
|
||||
// Prefer lang-specific font-family over default, if it exists
|
||||
FontTagXml* fontTagXml = langSpecificFont ? langSpecificFont : defaultFont;
|
||||
|
||||
// Pre-pend font family's path to make font family XML paths
|
||||
// relative to font family file
|
||||
fontTagXml->m_fontFilename = fontFamilyPath + fontTagXml->m_fontFilename;
|
||||
fontTagXml->m_boldFontFilename = fontFamilyPath + fontTagXml->m_boldFontFilename;
|
||||
fontTagXml->m_italicFontFilename = fontFamilyPath + fontTagXml->m_italicFontFilename;
|
||||
fontTagXml->m_boldItalicFontFilename = fontFamilyPath + fontTagXml->m_boldItalicFontFilename;
|
||||
|
||||
IFFont* normal = LoadFont(fontTagXml->m_fontFilename.c_str());
|
||||
IFFont* bold = LoadFont(fontTagXml->m_boldFontFilename.c_str());
|
||||
IFFont* italic = LoadFont(fontTagXml->m_italicFontFilename.c_str());
|
||||
IFFont* boldItalic = LoadFont(fontTagXml->m_boldItalicFontFilename.c_str());
|
||||
|
||||
// Only continue if all fonts were created successfully
|
||||
if (normal && bold && italic && boldItalic)
|
||||
{
|
||||
fontFamily.reset(new FontFamily(),
|
||||
[this](FontFamily* pFontFamily)
|
||||
{
|
||||
ReleaseFontFamily(pFontFamily);
|
||||
});
|
||||
|
||||
// Map the font family name both by path and by name defined
|
||||
// within the Font Family XML itself. This allows font
|
||||
// families to also be referenced simply by name.
|
||||
if (!AddFontFamilyToMaps(fontFamilyFullPath, xmlData.m_fontFamilyName, fontFamily))
|
||||
{
|
||||
SAFE_RELEASE(normal);
|
||||
SAFE_RELEASE(bold);
|
||||
SAFE_RELEASE(italic);
|
||||
SAFE_RELEASE(boldItalic);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
fontFamily->familyName = xmlData.m_fontFamilyName;
|
||||
fontFamily->normal = normal;
|
||||
fontFamily->bold = bold;
|
||||
fontFamily->italic = italic;
|
||||
fontFamily->boldItalic = boldItalic;
|
||||
}
|
||||
else
|
||||
{
|
||||
SAFE_RELEASE(normal);
|
||||
SAFE_RELEASE(bold);
|
||||
SAFE_RELEASE(italic);
|
||||
SAFE_RELEASE(boldItalic);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!fontFamily)
|
||||
{
|
||||
// Unable to load font family XML, so load font normally and associate
|
||||
// it with a font family
|
||||
IFFont* pFont = LoadFont(pFontFamilyName);
|
||||
|
||||
if (pFont)
|
||||
{
|
||||
// Create a font family from a single font by assigning all the
|
||||
// font family stylings to the same font
|
||||
fontFamily.reset(new FontFamily(),
|
||||
[this](FontFamily* pFontFamily)
|
||||
{
|
||||
ReleaseFontFamily(pFontFamily);
|
||||
});
|
||||
|
||||
// Use filepath as familyName so font loading/unloading doesn't break with duplicate file names
|
||||
fontFamily->familyName = pFontFamilyName;
|
||||
|
||||
if (!AddFontFamilyToMaps(pFontFamilyName, fontFamily->familyName, fontFamily))
|
||||
{
|
||||
SAFE_RELEASE(pFont);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Assign all stylings to the same font
|
||||
fontFamily->normal = pFont;
|
||||
fontFamily->bold = pFont;
|
||||
fontFamily->italic = pFont;
|
||||
fontFamily->boldItalic = pFont;
|
||||
|
||||
// The other three stylings need to have their ref count
|
||||
// incremented (even though in this particular case its all the
|
||||
// same font) because when ReleaseFontFamily executes all fonts
|
||||
// in the family will be (corresondingly) Release'd.
|
||||
fontFamily->bold->AddRef();
|
||||
fontFamily->italic->AddRef();
|
||||
fontFamily->boldItalic->AddRef();
|
||||
}
|
||||
}
|
||||
|
||||
// Persist fonts for application lifetime to prevent unnecessary work
|
||||
if (r_persistFontFamilies > 0)
|
||||
{
|
||||
m_persistedFontFamilies.emplace_back(FontFamilyPtr(fontFamily));
|
||||
}
|
||||
|
||||
return fontFamily;
|
||||
}
|
||||
|
||||
FontFamilyPtr CCryFont::GetFontFamily(const char* pFontFamilyName)
|
||||
{
|
||||
FontFamilyPtr fontFamily = nullptr;
|
||||
|
||||
// The given string could either be: a font family name (defined in font
|
||||
// family XML), a file path (for regular fonts mapped as font families),
|
||||
// or just the filename of a font itself. Fonts are mapped by font family
|
||||
// name or by filepath, so attempt lookup using the map first since it's
|
||||
// the fastest.
|
||||
string loweredName = string(pFontFamilyName).Trim().MakeLower();
|
||||
auto it = m_fontFamilies.find(PathUtil::MakeGamePath(loweredName).c_str());
|
||||
if (it != m_fontFamilies.end())
|
||||
{
|
||||
fontFamily = FontFamilyPtr(it->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Iterate through all fonts, returning the first match where simply
|
||||
// the filename of a font could be a match. This case will likely be
|
||||
// hit when text markup references a font that doesn't belong to a
|
||||
// font family.
|
||||
for (const auto& fontFamilyIter : m_fontFamilies)
|
||||
{
|
||||
const AZStd::string& mappedFontFamilyName = fontFamilyIter.first;
|
||||
string mappedFilenameNoExtension = PathUtil::GetFileName(mappedFontFamilyName.c_str());
|
||||
|
||||
string searchStringFilenameNoExtension = PathUtil::GetFileName(loweredName);
|
||||
|
||||
if (mappedFilenameNoExtension == searchStringFilenameNoExtension)
|
||||
{
|
||||
fontFamily = FontFamilyPtr(fontFamilyIter.second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fontFamily;
|
||||
}
|
||||
|
||||
void CCryFont::AddCharsToFontTextures(FontFamilyPtr pFontFamily, const char* pChars, int glyphSizeX, int glyphSizeY)
|
||||
{
|
||||
pFontFamily->normal->AddCharsToFontTexture(pChars, glyphSizeX, glyphSizeY);
|
||||
pFontFamily->bold->AddCharsToFontTexture(pChars, glyphSizeX, glyphSizeY);
|
||||
pFontFamily->italic->AddCharsToFontTexture(pChars, glyphSizeX, glyphSizeY);
|
||||
pFontFamily->boldItalic->AddCharsToFontTexture(pChars, glyphSizeX, glyphSizeY);
|
||||
}
|
||||
|
||||
void CCryFont::SetRendererProperties(IRenderer* pRenderer)
|
||||
{
|
||||
if (pRenderer)
|
||||
{
|
||||
m_rndPropIsRGBA = (pRenderer->GetFeatures() & RFT_RGBA) != 0;
|
||||
m_rndPropHalfTexelOffset = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void CCryFont::GetMemoryUsage(ICrySizer* pSizer) const
|
||||
{
|
||||
if (!pSizer->Add(*this))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pSizer->AddObject(m_fonts);
|
||||
}
|
||||
|
||||
string CCryFont::GetLoadedFontNames() const
|
||||
{
|
||||
string ret;
|
||||
for (FontMapConstItor it = m_fonts.begin(), itEnd = m_fonts.end(); it != itEnd; ++it)
|
||||
{
|
||||
CFFont* pFont = it->second;
|
||||
if (pFont)
|
||||
{
|
||||
if (!ret.empty())
|
||||
{
|
||||
ret += ",";
|
||||
}
|
||||
ret += pFont->GetName();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CCryFont::OnLanguageChanged()
|
||||
{
|
||||
ReloadAllFonts();
|
||||
|
||||
EBUS_EVENT(LanguageChangeNotificationBus, LanguageChanged);
|
||||
}
|
||||
|
||||
void CCryFont::ReloadAllFonts()
|
||||
{
|
||||
// Persist fonts for application lifetime to prevent unnecessary work
|
||||
m_persistedFontFamilies.clear();
|
||||
|
||||
AZStd::list<AZStd::string> fontFamilyFilenames;
|
||||
AZStd::list<FontFamily*> fontFamilyWeakPtrs;
|
||||
|
||||
// Iterate through all currently loaded font families
|
||||
for (auto it : m_fontFamilyReverseLookup)
|
||||
{
|
||||
fontFamilyWeakPtrs.push_back(it.first);
|
||||
fontFamilyFilenames.push_back(it.second->first);
|
||||
}
|
||||
|
||||
// Release font-family resources and unmap them
|
||||
for (auto fontFamily : fontFamilyWeakPtrs)
|
||||
{
|
||||
ReleaseFontFamily(fontFamily);
|
||||
}
|
||||
|
||||
// Reload the font families
|
||||
for (auto familyFilename : fontFamilyFilenames)
|
||||
{
|
||||
LoadFontFamily(familyFilename.c_str());
|
||||
}
|
||||
|
||||
// All UI text components need to reload their font assets (both in-game
|
||||
// and in-editor).
|
||||
EBUS_EVENT(FontNotificationBus, OnFontsReloaded);
|
||||
}
|
||||
|
||||
void CCryFont::UnregisterFont(const char* pFontName)
|
||||
{
|
||||
FontMapItor it = m_fonts.find(CONST_TEMP_STRING(pFontName));
|
||||
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
IFFont* fontPtr = it->second;
|
||||
#endif
|
||||
|
||||
if (it != m_fonts.end())
|
||||
{
|
||||
m_fonts.erase(it);
|
||||
}
|
||||
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
// Make sure the font being released isn't currently in use by a font family.
|
||||
// If it is, the FontFamily will have a dangling pointer and will cause a
|
||||
// crash when the FontFamily eventually gets released.
|
||||
for (auto reverseMapEntry : m_fontFamilyReverseLookup)
|
||||
{
|
||||
FontFamily* fontFamily = reverseMapEntry.first;
|
||||
AZ_Assert(fontFamily->normal != fontPtr,
|
||||
"The following font is being freed but still in use by a FontFamily: %s",
|
||||
pFontName);
|
||||
AZ_Assert(fontFamily->italic != fontPtr,
|
||||
"The following font is being freed but still in use by a FontFamily: %s",
|
||||
pFontName);
|
||||
AZ_Assert(fontFamily->bold != fontPtr,
|
||||
"The following font is being freed but still in use by a FontFamily: %s",
|
||||
pFontName);
|
||||
AZ_Assert(fontFamily->boldItalic != fontPtr,
|
||||
"The following font is being freed but still in use by a FontFamily: %s",
|
||||
pFontName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
IFFont* CCryFont::LoadFont(const char* pFontName)
|
||||
{
|
||||
string fontName = pFontName;
|
||||
fontName.MakeLower();
|
||||
|
||||
IFFont* font = GetFont(fontName);
|
||||
if (font)
|
||||
{
|
||||
font->AddRef(); // use existing loaded font
|
||||
}
|
||||
else
|
||||
{
|
||||
// attempt to create and load a new font, use the font pathname as the font name
|
||||
font = NewFont(fontName);
|
||||
if (!font)
|
||||
{
|
||||
string errorMsg = "Error creating a new font named ";
|
||||
errorMsg += fontName;
|
||||
errorMsg += ".";
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR, errorMsg.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
// creating font adds one to its refcount so no need for AddRef here
|
||||
if (!font->Load(fontName))
|
||||
{
|
||||
string errorMsg = "Error loading a font from ";
|
||||
errorMsg += fontName;
|
||||
errorMsg += ".";
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR, errorMsg);
|
||||
font->Release();
|
||||
font = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
void CCryFont::ReleaseFontFamily(FontFamily* pFontFamily)
|
||||
{
|
||||
// Ensure that Font Family was mapped prior to destruction
|
||||
const bool isMapped = m_fontFamilyReverseLookup.find(pFontFamily) != m_fontFamilyReverseLookup.end();
|
||||
if (!isMapped)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Note that the FontFamily is mapped both by filename and by "family name"
|
||||
auto it = m_fontFamilyReverseLookup[pFontFamily];
|
||||
m_fontFamilies.erase(it);
|
||||
string familyName(pFontFamily->familyName);
|
||||
m_fontFamilies.erase(familyName.MakeLower().c_str());
|
||||
|
||||
// Reverse lookup is used to avoid needing to store filename path with
|
||||
// the font family, so we need to remove that entry also.
|
||||
m_fontFamilyReverseLookup.erase(pFontFamily);
|
||||
|
||||
SAFE_RELEASE(pFontFamily->normal);
|
||||
SAFE_RELEASE(pFontFamily->bold);
|
||||
SAFE_RELEASE(pFontFamily->italic);
|
||||
SAFE_RELEASE(pFontFamily->boldItalic);
|
||||
}
|
||||
|
||||
bool CCryFont::AddFontFamilyToMaps(const char* pFontFamilyFilename, const char* pFontFamilyName, FontFamilyPtr fontFamily)
|
||||
{
|
||||
if (!pFontFamilyFilename || !pFontFamilyName || !fontFamily.get())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// We don't support "updating" mapped values.
|
||||
AZStd::string loweredFilename(PathUtil::MakeGamePath(string(pFontFamilyFilename)).c_str());
|
||||
AZStd::to_lower<AZStd::string::iterator>(loweredFilename.begin(), loweredFilename.end());
|
||||
if (m_fontFamilies.find(loweredFilename) != m_fontFamilies.end())
|
||||
{
|
||||
string warnMsg;
|
||||
warnMsg.Format("Couldn't load Font Family '%s': already loaded", pFontFamilyFilename);
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, warnMsg.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Similarly, we don't support Font Family XMLs that have the same font
|
||||
// family name (we assume all Font Family names are unique).
|
||||
AZStd::string loweredFontFamilyName(pFontFamilyName);
|
||||
AZStd::to_lower<AZStd::string::iterator>(loweredFontFamilyName.begin(), loweredFontFamilyName.end());
|
||||
if (m_fontFamilies.find(loweredFontFamilyName) != m_fontFamilies.end())
|
||||
{
|
||||
string warnMsg;
|
||||
warnMsg.Format("Couldn't load Font Family '%s': already loaded", pFontFamilyName);
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, warnMsg.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// First, insert by filename
|
||||
AZStd::pair<AZStd::string, AZStd::weak_ptr<FontFamily>> insertPair(loweredFilename, fontFamily);
|
||||
auto iterPosition = m_fontFamilies.insert(insertPair).first;
|
||||
m_fontFamilyReverseLookup[fontFamily.get()] = iterPosition;
|
||||
|
||||
// Then, by Font Family name
|
||||
AZStd::pair<AZStd::string, AZStd::weak_ptr<FontFamily>> nameInsertPair(loweredFontFamilyName, fontFamily);
|
||||
m_fontFamilies.insert(nameInsertPair);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
XmlNodeRef CCryFont::LoadFontFamilyXml(const char* pFontFamilyName, string& outputDirectory, string& outputFullPath)
|
||||
{
|
||||
outputFullPath = pFontFamilyName;
|
||||
outputDirectory = PathUtil::GetPath(pFontFamilyName);
|
||||
XmlNodeRef root = SafeLoadXmlFromFile(outputFullPath);
|
||||
|
||||
// When parsing a <font> tag in markup, only the font name is given and
|
||||
// not a path, so we try to build a "best guess" path from the name.
|
||||
if (!root)
|
||||
{
|
||||
string fileNoExtension(PathUtil::GetFileName(pFontFamilyName));
|
||||
string fileExtension(PathUtil::GetExt(pFontFamilyName));
|
||||
|
||||
if (fileExtension.empty())
|
||||
{
|
||||
fileExtension = ".fontfamily";
|
||||
}
|
||||
|
||||
// Try: "fonts/fontName.fontfamily"
|
||||
outputDirectory = string("fonts/");
|
||||
outputFullPath = outputDirectory + fileNoExtension + fileExtension;
|
||||
root = SafeLoadXmlFromFile(outputFullPath);
|
||||
|
||||
// Finally, try: "fonts/fontName/fontName.fontfamily"
|
||||
if (!root)
|
||||
{
|
||||
outputDirectory = string("fonts/") + fileNoExtension + "/";
|
||||
outputFullPath = outputDirectory + fileNoExtension + fileExtension;
|
||||
root = SafeLoadXmlFromFile(outputFullPath);
|
||||
}
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
EXPORTS
|
||||
ModuleInitISystem @2
|
||||
CryModuleGetMemoryInfo @8
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_CRYFONT_CRYFONT_H
|
||||
#define CRYINCLUDE_CRYFONT_CRYFONT_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#include <IXml.h>
|
||||
#include <AzCore/std/containers/map.h>
|
||||
#include <AzCore/std/smart_ptr/weak_ptr.h>
|
||||
#include <map>
|
||||
|
||||
class CFFont;
|
||||
|
||||
|
||||
class CCryFont
|
||||
: public ICryFont
|
||||
{
|
||||
friend class CFFont;
|
||||
|
||||
public:
|
||||
|
||||
static const Vec2i defaultGlyphSize; //!< Default glyph size indicates that glyphs in the font texture
|
||||
//!< should be rendered at the maximum resolution supported by
|
||||
//!< the font texture's glyph cell/slot configuration (configured
|
||||
//!< via font XML).
|
||||
|
||||
public:
|
||||
CCryFont(ISystem* pSystem);
|
||||
virtual ~CCryFont();
|
||||
|
||||
virtual void Release();
|
||||
virtual IFFont* NewFont(const char* pFontName);
|
||||
virtual IFFont* GetFont(const char* pFontName) const;
|
||||
virtual FontFamilyPtr LoadFontFamily(const char* pFontFamilyName) override;
|
||||
virtual FontFamilyPtr GetFontFamily(const char* pFontFamilyName) override;
|
||||
virtual void AddCharsToFontTextures(FontFamilyPtr pFontFamily, const char* pChars, int glyphSizeX = ICryFont::defaultGlyphSizeX, int glyphSizeY = ICryFont::defaultGlyphSizeY) override;
|
||||
virtual void SetRendererProperties(IRenderer* pRenderer);
|
||||
virtual void GetMemoryUsage(ICrySizer* pSizer) const;
|
||||
virtual string GetLoadedFontNames() const;
|
||||
virtual void OnLanguageChanged() override;
|
||||
virtual void ReloadAllFonts() override;
|
||||
|
||||
public:
|
||||
void UnregisterFont(const char* pFontName);
|
||||
bool RndPropIsRGBA() const { return m_rndPropIsRGBA; }
|
||||
float RndPropHalfTexelOffset() const { return m_rndPropHalfTexelOffset; }
|
||||
|
||||
private:
|
||||
typedef std::map<string, CFFont*> FontMap;
|
||||
typedef FontMap::iterator FontMapItor;
|
||||
typedef FontMap::const_iterator FontMapConstItor;
|
||||
|
||||
typedef AZStd::map<AZStd::string, AZStd::weak_ptr<FontFamily>> FontFamilyMap;
|
||||
typedef AZStd::map<FontFamily*, FontFamilyMap::iterator> FontFamilyReverseLookupMap;
|
||||
|
||||
private:
|
||||
//! Convenience method for loading fonts
|
||||
IFFont* LoadFont(const char* fontName);
|
||||
|
||||
//! Called when final FontFamily shared_ptr is destroyed; do not call directly.
|
||||
void ReleaseFontFamily(FontFamily* pFontFamily);
|
||||
|
||||
//! Adds new entries into both font family maps for the given font family
|
||||
//!
|
||||
//! Note that it's not possible to update Font Family mappings with this
|
||||
//! method. The only way to do that would be to release the font family
|
||||
//! and re-load it with the new values.
|
||||
//!
|
||||
//! \return True only if the Font Family was added to the maps, false for all other cases (such as
|
||||
//! when the font family is already mapped).
|
||||
bool AddFontFamilyToMaps(const char* pFontFamilyFilename, const char* pFontFamilyName, FontFamilyPtr fontFamily);
|
||||
|
||||
//! Internal method that (possibly) makes several attempts at locating and loading a given font family XML.
|
||||
//! \param pFontFamilyName The name of the font family, or path to a font family file.
|
||||
//! \param outputDirectory Path to loaded font family (no filename), may need resolving with PathUtil::MakeGamePath.
|
||||
//! \param outputFullPath Full path to loaded font family, may need resolving with PathUtil::MakeGamePath.
|
||||
XmlNodeRef LoadFontFamilyXml(const char* pFontFamilyName, string& outputDirectory, string& outputFullPath);
|
||||
|
||||
private:
|
||||
FontMap m_fonts;
|
||||
FontFamilyMap m_fontFamilies; //!< Map font family names to weak ptrs so we can construct shared_ptrs but not keep a ref ourselves.
|
||||
FontFamilyReverseLookupMap m_fontFamilyReverseLookup; //<! FontFamily pointer reverse-lookup for quick removal
|
||||
ISystem* m_pSystem;
|
||||
bool m_rndPropIsRGBA;
|
||||
float m_rndPropHalfTexelOffset;
|
||||
|
||||
int r_persistFontFamilies = 1; //!< Persist fonts for application lifetime to prevent unnecessary work; enabled by default.
|
||||
AZStd::vector<FontFamilyPtr> m_persistedFontFamilies; //!< Stores persisted fonts (if "persist font families" is enabled)
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CRYINCLUDE_CRYFONT_CRYFONT_H
|
||||
@@ -1,111 +0,0 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Russian resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
|
||||
#pragma code_page(1251)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Russian resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// German (Germany) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "000904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Amazon.com, Inc."
|
||||
VALUE "FileVersion", "1, 0, 0, 1"
|
||||
VALUE "LegalCopyright", "Portions of this file Copyright (c) Amazon.com, Inc. or its affiliates. All Rights Reserved. Original file Copyright (c) Crytek GMBH. Used under license by Amazon.com, Inc. and its affiliates."
|
||||
VALUE "ProductName", "Lumberyard"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x9, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // German (Germany) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#define CRYFONT_EXPORTS
|
||||
|
||||
#include <platform.h>
|
||||
|
||||
#include <IFont.h>
|
||||
|
||||
#include <ILog.h>
|
||||
#include <IConsole.h>
|
||||
#include <IRenderer.h>
|
||||
#include <CrySizer.h>
|
||||
|
||||
#define USE_NULLFONT
|
||||
|
||||
#if defined(DEDICATED_SERVER)
|
||||
#define USE_NULLFONT_ALWAYS 1
|
||||
#endif
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#pragma once
|
||||
#ifndef CRYINCLUDE_CRYFONT_FBITMAP_H
|
||||
#define CRYINCLUDE_CRYFONT_FBITMAP_H
|
||||
|
||||
|
||||
class CFBitmap
|
||||
{
|
||||
public:
|
||||
CFBitmap();
|
||||
~CFBitmap();
|
||||
|
||||
int Blur(int iIterations);
|
||||
int Scale(float fScaleX, float fScaleY);
|
||||
|
||||
int BlitFrom(CFBitmap* pSrc, int iSX, int iSY, int iDX, int iDY, int iW, int iH);
|
||||
int BlitTo(CFBitmap* pDst, int iDX, int iDY, int iSX, int iSY, int iW, int iH);
|
||||
|
||||
int Create(int iWidth, int iHeight);
|
||||
int Release();
|
||||
|
||||
int SaveBitmap(const string& szFileName);
|
||||
int Get32Bpp(unsigned int** pBuffer)
|
||||
{
|
||||
(*pBuffer) = new unsigned int[m_iWidth * m_iHeight];
|
||||
|
||||
if (!(*pBuffer))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iDataSize = m_iWidth * m_iHeight;
|
||||
|
||||
for (int i = 0; i < iDataSize; i++)
|
||||
{
|
||||
(*pBuffer)[i] = (m_pData[i] << 24) | (m_pData[i] << 16) | (m_pData[i] << 8) | (m_pData[i]);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetWidth() { return m_iWidth; }
|
||||
int GetHeight() { return m_iHeight; }
|
||||
|
||||
void SetRenderData(void* pRenderData) { m_pIRenderData = pRenderData; };
|
||||
void* GetRenderData() { return m_pIRenderData; };
|
||||
|
||||
void GetMemoryUsage (class ICrySizer* pSizer);
|
||||
|
||||
unsigned char* GetData() { return m_pData; }
|
||||
|
||||
public:
|
||||
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
|
||||
unsigned char* m_pData;
|
||||
void* m_pIRenderData;
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYFONT_FBITMAP_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,234 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Font class.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYFONT_FFONT_H
|
||||
#define CRYINCLUDE_CRYFONT_FFONT_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#include <vector>
|
||||
#include <Cry_Math.h>
|
||||
#include <Cry_Color.h>
|
||||
#include <CryString.h>
|
||||
#include "CryFont.h"
|
||||
|
||||
#include <AzCore/std/parallel/mutex.h>
|
||||
|
||||
struct ISystem;
|
||||
class CFontTexture;
|
||||
|
||||
|
||||
class CFFont
|
||||
: public IFFont
|
||||
, public IFFont_RenderProxy
|
||||
{
|
||||
public:
|
||||
//! Determines how characters of different sizes should be handled during render.
|
||||
enum class SizeBehavior
|
||||
{
|
||||
Scale, //!< Default behavior; glyphs rendered at different sizes are rendered on scaled geometry
|
||||
Rerender //!< Similar to Scale, but the glyph in the font texture is re-rendered to match the target
|
||||
//!< size, as long as the size isn't greater than the maximum glyph/slot resolution as
|
||||
//!< configured for the font texture in the font XML.
|
||||
};
|
||||
|
||||
//! The hinting visual algorithm to be used (when hinting is enabled)
|
||||
enum class HintStyle
|
||||
{
|
||||
Normal, //!< Default hinting behavior provided by font renderer
|
||||
Light //!< Produces fuzzier glyphs but more accurately tracks glyph shape
|
||||
};
|
||||
|
||||
//! Chooses whether hinting info should be obtained from the font, turned off entirely, or automatically generated
|
||||
enum class HintBehavior
|
||||
{
|
||||
Default, //!< Obtain hinting data from font itself
|
||||
AutoHint, //!< Procedurally derive hinting information from glyph
|
||||
NoHinting, //!< Disable hinting entirely
|
||||
};
|
||||
|
||||
//! Simple struct used to communicate font hinting parameters to font renderer.
|
||||
struct FontHintParams
|
||||
{
|
||||
FontHintParams() : hintStyle(HintStyle::Normal), hintBehavior(HintBehavior::Default) { }
|
||||
|
||||
HintStyle hintStyle;
|
||||
HintBehavior hintBehavior;
|
||||
};
|
||||
|
||||
struct SRenderingPass
|
||||
{
|
||||
ColorB m_color;
|
||||
Vec2 m_posOffset;
|
||||
int m_blendSrc;
|
||||
int m_blendDest;
|
||||
|
||||
SRenderingPass()
|
||||
: m_color(255, 255, 255, 255)
|
||||
, m_posOffset(0, 0)
|
||||
, m_blendSrc(GS_BLSRC_SRCALPHA)
|
||||
, m_blendDest(GS_BLDST_ONEMINUSSRCALPHA)
|
||||
{
|
||||
}
|
||||
|
||||
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const {}
|
||||
};
|
||||
|
||||
struct SEffect
|
||||
{
|
||||
string m_name;
|
||||
std::vector<SRenderingPass> m_passes;
|
||||
|
||||
SEffect(const char* name)
|
||||
: m_name(name)
|
||||
{
|
||||
assert(name);
|
||||
}
|
||||
|
||||
SRenderingPass* AddPass()
|
||||
{
|
||||
m_passes.push_back(SRenderingPass());
|
||||
return &m_passes[m_passes.size() - 1];
|
||||
}
|
||||
|
||||
void ClearPasses()
|
||||
{
|
||||
m_passes.resize(0);
|
||||
}
|
||||
|
||||
void GetMemoryUsage(ICrySizer* pSizer) const
|
||||
{
|
||||
pSizer->AddObject(m_name);
|
||||
pSizer->AddObject(m_passes);
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::vector<SEffect> Effects;
|
||||
typedef Effects::iterator EffectsIt;
|
||||
|
||||
public:
|
||||
virtual int32 AddRef() override;
|
||||
virtual int32 Release() override;
|
||||
virtual bool Load(const char* pFontFilePath, unsigned int width, unsigned int height, unsigned int widthNumSlots, unsigned int heightNumSlots, unsigned int flags, float sizeRatio);
|
||||
virtual bool Load(const char* pXMLFile);
|
||||
virtual void Free();
|
||||
virtual void DrawString(float x, float y, const char* pStr, const bool asciiMultiLine, const STextDrawContext& ctx);
|
||||
virtual void DrawString(float x, float y, float z, const char* pStr, const bool asciiMultiLine, const STextDrawContext& ctx);
|
||||
virtual Vec2 GetTextSize(const char* pStr, const bool asciiMultiLine, const STextDrawContext& ctx);
|
||||
virtual size_t GetTextLength(const char* pStr, const bool asciiMultiLine) const;
|
||||
virtual void WrapText(string& result, float maxWidth, const char* pStr, const STextDrawContext& ctx);
|
||||
virtual void GetMemoryUsage(ICrySizer* pSizer) const;
|
||||
virtual void GetGradientTextureCoord(float& minU, float& minV, float& maxU, float& maxV) const;
|
||||
virtual unsigned int GetEffectId(const char* pEffectName) const;
|
||||
virtual unsigned int GetNumEffects() const;
|
||||
virtual const char* GetEffectName(unsigned int effectId) const;
|
||||
virtual Vec2 GetMaxEffectOffset(unsigned int effectId) const;
|
||||
virtual bool DoesEffectHaveTransparency(unsigned int effectId) const;
|
||||
virtual void AddCharsToFontTexture(const char* pChars, int glyphSizeX = ICryFont::defaultGlyphSizeX, int glyphSizeY = ICryFont::defaultGlyphSizeY) override;
|
||||
virtual Vec2 GetKerning(uint32_t leftGlyph, uint32_t rightGlyph, const STextDrawContext& ctx) const override;
|
||||
virtual float GetAscender(const STextDrawContext& ctx) const override;
|
||||
virtual float GetBaseline(const STextDrawContext& ctx) const override;
|
||||
|
||||
virtual uint32 GetNumQuadsForText(const char* pStr, const bool asciiMultiLine, const STextDrawContext& ctx);
|
||||
virtual uint32 WriteTextQuadsToBuffers(SVF_P2F_C4B_T2F_F4B* verts, uint16* indices, uint32 maxQuads, float x, float y, float z, const char* pStr, const bool asciiMultiLine, const STextDrawContext& ctx);
|
||||
virtual int GetFontTextureId();
|
||||
virtual uint32 GetFontTextureVersion();
|
||||
|
||||
virtual float GetSizeRatio() const override { return m_sizeRatio; }
|
||||
|
||||
public:
|
||||
virtual void RenderCallback(float x, float y, float z, const char* pStr, const bool asciiMultiLine, const STextDrawContext& ctx);
|
||||
|
||||
public:
|
||||
CFFont(ISystem* pSystem, CCryFont* pCryFont, const char* pFontName);
|
||||
|
||||
bool InitTexture();
|
||||
bool InitCache();
|
||||
|
||||
CFontTexture* GetFontTexture() const { return m_pFontTexture; }
|
||||
const string& GetName() const { return m_name; }
|
||||
|
||||
SEffect* AddEffect(const char* pEffectName);
|
||||
SEffect* GetDefaultEffect();
|
||||
|
||||
private:
|
||||
virtual ~CFFont();
|
||||
|
||||
void Prepare(const char* pStr, bool updateTexture, const Vec2i& glyphSize = CCryFont::defaultGlyphSize);
|
||||
void DrawStringUInternal(float x, float y, float z, const char* pStr, const bool asciiMultiLine, const STextDrawContext& ctx);
|
||||
Vec2 GetTextSizeUInternal(const char* pStr, const bool asciiMultiLine, const STextDrawContext& ctx);
|
||||
|
||||
using AddFunction = AZStd::function<void(const Vec3&, const Vec3&, const Vec3&, const Vec3&, const Vec2&, const Vec2&, const Vec2&, const Vec2&, uint32)>;
|
||||
using BeginPassFunction = AZStd::function<void(const SRenderingPass* pPass)>;
|
||||
|
||||
//! This function is used by both RenderCallback and WriteTextQuadsToBuffers
|
||||
//! To do this is takes two function pointers that implement the appropriate AddQuad and BeginPass behavior
|
||||
void CreateQuadsForText(float x, float y, float z, const char* pStr, const bool asciiMultiLine, const STextDrawContext& ctx,
|
||||
AddFunction AddQuad, BeginPassFunction BeginPass);
|
||||
|
||||
struct TextScaleInfoInternal
|
||||
{
|
||||
TextScaleInfoInternal(const Vec2& _scale, float _rcpCellWidth)
|
||||
: scale(_scale), rcpCellWidth(_rcpCellWidth) { }
|
||||
|
||||
Vec2 scale;
|
||||
float rcpCellWidth;
|
||||
};
|
||||
|
||||
TextScaleInfoInternal CalculateScaleInternal(const STextDrawContext& ctx) const;
|
||||
|
||||
Vec2 GetRestoredFontSize(const STextDrawContext& ctx) const;
|
||||
|
||||
private:
|
||||
string m_name;
|
||||
string m_curPath;
|
||||
|
||||
CFontTexture* m_pFontTexture;
|
||||
|
||||
size_t m_fontBufferSize;
|
||||
unsigned char* m_pFontBuffer;
|
||||
|
||||
int m_texID;
|
||||
uint32 m_textureVersion;
|
||||
|
||||
ISystem* m_pSystem;
|
||||
|
||||
AZStd::recursive_mutex m_fontMutex; //!< Controls access between main and render threads. It's common for one thread
|
||||
//!< to add un-cached glyphs to the font texture while another is accessing the
|
||||
//!< font texture.
|
||||
|
||||
CCryFont* m_pCryFont;
|
||||
|
||||
bool m_fontTexDirty;
|
||||
|
||||
Effects m_effects;
|
||||
|
||||
SVF_P3F_C4B_T2F* m_pDrawVB;
|
||||
|
||||
volatile int32 m_nRefCount;
|
||||
|
||||
bool m_monospacedFont; //!< True if this font is fixed/monospaced, false otherwise (obtained from FreeType)
|
||||
|
||||
float m_sizeRatio = IFFontConstants::defaultSizeRatio;
|
||||
SizeBehavior m_sizeBehavior = SizeBehavior::Scale; //!< Changes how glyphs rendered at different sizes are rendered.
|
||||
FontHintParams m_fontHintParams; //!< How the font should be hinted when its loaded and rendered to the font texture
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CRYINCLUDE_CRYFONT_FFONT_H
|
||||
@@ -1,448 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : XML parsing to load a font.
|
||||
|
||||
|
||||
#include "CryFont_precompiled.h"
|
||||
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#include "FFont.h"
|
||||
#include "FontTexture.h"
|
||||
#include <Cry_Math.h>
|
||||
#include <CryPath.h>
|
||||
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
# include <shlobj.h>
|
||||
# include <StringUtils.h>
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Xml parser implementation
|
||||
|
||||
enum
|
||||
{
|
||||
|
||||
ELEMENT_UNKNOWN = 0,
|
||||
ELEMENT_FONT = 1,
|
||||
ELEMENT_EFFECT = 2,
|
||||
ELEMENT_EFFECTFILE = 3,
|
||||
ELEMENT_PASS = 4,
|
||||
ELEMENT_PASS_COLOR = 5,
|
||||
ELEMENT_PASS_POSOFFSET = 12,
|
||||
ELEMENT_PASS_BLEND = 14
|
||||
};
|
||||
|
||||
static inline int GetBlendModeFromString(const string& str, bool dst)
|
||||
{
|
||||
int blend = GS_BLSRC_ONE;
|
||||
|
||||
if (str == "zero")
|
||||
{
|
||||
blend = dst ? GS_BLDST_ZERO : GS_BLSRC_ZERO;
|
||||
}
|
||||
else if (str == "one")
|
||||
{
|
||||
blend = dst ? GS_BLDST_ONE : GS_BLSRC_ONE;
|
||||
}
|
||||
else if (str == "srcalpha" ||
|
||||
str == "src_alpha")
|
||||
{
|
||||
blend = dst ? GS_BLDST_SRCALPHA : GS_BLSRC_SRCALPHA;
|
||||
}
|
||||
else if (str == "invsrcalpha" ||
|
||||
str == "inv_src_alpha")
|
||||
{
|
||||
blend = dst ? GS_BLDST_ONEMINUSSRCALPHA : GS_BLSRC_ONEMINUSSRCALPHA;
|
||||
}
|
||||
else if (str == "dstalpha" ||
|
||||
str == "dst_alpha")
|
||||
{
|
||||
blend = dst ? GS_BLDST_DSTALPHA : GS_BLSRC_DSTALPHA;
|
||||
}
|
||||
else if (str == "invdstalpha" ||
|
||||
str == "inv_dst_alpha")
|
||||
{
|
||||
blend = dst ? GS_BLDST_ONEMINUSDSTALPHA : GS_BLSRC_ONEMINUSDSTALPHA;
|
||||
}
|
||||
else if (str == "dstcolor" ||
|
||||
str == "dst_color")
|
||||
{
|
||||
blend = GS_BLSRC_DSTCOL;
|
||||
}
|
||||
else if (str == "srccolor" ||
|
||||
str == "src_color")
|
||||
{
|
||||
blend = GS_BLDST_SRCCOL;
|
||||
}
|
||||
else if (str == "invdstcolor" ||
|
||||
str == "inv_dst_color")
|
||||
{
|
||||
blend = GS_BLSRC_ONEMINUSDSTCOL;
|
||||
}
|
||||
else if (str == "invsrccolor" ||
|
||||
str == "inv_src_color")
|
||||
{
|
||||
blend = GS_BLDST_ONEMINUSSRCCOL;
|
||||
}
|
||||
|
||||
return blend;
|
||||
}
|
||||
|
||||
class CXmlFontShader
|
||||
{
|
||||
public:
|
||||
CXmlFontShader(CFFont* pFont)
|
||||
{
|
||||
m_pFont = pFont;
|
||||
m_nElement = ELEMENT_UNKNOWN;
|
||||
m_pEffect = NULL;
|
||||
m_pPass = NULL;
|
||||
m_FontTexSize.set(0, 0);
|
||||
|
||||
static const int defaultSlotWidthSize = 16;
|
||||
static const int defaultSlotHeightSize = 8;
|
||||
m_SlotSizes.set(defaultSlotWidthSize, defaultSlotHeightSize);
|
||||
|
||||
m_FontSmoothAmount = 0;
|
||||
m_FontSmoothMethod = FONT_SMOOTH_NONE;
|
||||
}
|
||||
|
||||
~CXmlFontShader()
|
||||
{
|
||||
}
|
||||
|
||||
void ScanXmlNodesRecursively(XmlNodeRef node)
|
||||
{
|
||||
if (!node)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FoundElement(node->getTag());
|
||||
|
||||
for (int i = 0, count = node->getNumAttributes(); i < count; ++i)
|
||||
{
|
||||
const char* key = "";
|
||||
const char* value = "";
|
||||
if (node->getAttributeByIndex(i, &key, &value))
|
||||
{
|
||||
FoundAttribute(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0, count = node->getChildCount(); i < count; ++i)
|
||||
{
|
||||
XmlNodeRef child = node->getChild(i);
|
||||
ScanXmlNodesRecursively(child);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// notify methods
|
||||
void FoundElement(const string& name)
|
||||
{
|
||||
//MessageBox(NULL, string("[" + name + "]").c_str(), "FoundElement", MB_OK);
|
||||
// process the previous element
|
||||
switch (m_nElement)
|
||||
{
|
||||
case ELEMENT_FONT:
|
||||
{
|
||||
if (!m_FontTexSize.x || !m_FontTexSize.y)
|
||||
{
|
||||
m_FontTexSize.set(512, 512);
|
||||
}
|
||||
|
||||
bool fontLoaded = m_pFont->Load(m_strFontPath.c_str(), m_FontTexSize.x, m_FontTexSize.y, m_SlotSizes.x, m_SlotSizes.y, TTFFLAG_CREATE(m_FontSmoothMethod, m_FontSmoothAmount), m_SizeRatio);
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
if (!fontLoaded)
|
||||
{
|
||||
TCHAR sysFontPath[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPath(0, CSIDL_FONTS, 0, SHGFP_TYPE_DEFAULT, sysFontPath)))
|
||||
{
|
||||
const char* pFontPath = m_strFontPath.c_str();
|
||||
const char* pFontName = CryStringUtils::FindFileNameInPath(pFontPath);
|
||||
|
||||
string newFontPath(sysFontPath);
|
||||
newFontPath += "/";
|
||||
newFontPath += pFontName;
|
||||
m_pFont->Load(newFontPath, m_FontTexSize.x, m_FontTexSize.y, m_SlotSizes.x, m_SlotSizes.y, TTFFLAG_CREATE(m_FontSmoothMethod, m_FontSmoothAmount), m_SizeRatio);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Translate the m_nElement name to a define
|
||||
if (name == "font")
|
||||
{
|
||||
m_nElement = ELEMENT_FONT;
|
||||
}
|
||||
else if (name == "effect")
|
||||
{
|
||||
m_nElement = ELEMENT_EFFECT;
|
||||
}
|
||||
else if (name == "effectfile")
|
||||
{
|
||||
m_nElement = ELEMENT_EFFECTFILE;
|
||||
}
|
||||
else if (name == "pass")
|
||||
{
|
||||
m_pPass = NULL;
|
||||
m_nElement = ELEMENT_PASS;
|
||||
if (m_pEffect)
|
||||
{
|
||||
m_pPass = m_pEffect->AddPass();
|
||||
}
|
||||
}
|
||||
else if (name == "color")
|
||||
{
|
||||
m_nElement = ELEMENT_PASS_COLOR;
|
||||
}
|
||||
else if (name == "pos" ||
|
||||
name == "offset")
|
||||
{
|
||||
m_nElement = ELEMENT_PASS_POSOFFSET;
|
||||
}
|
||||
else if (name == "blend" ||
|
||||
name == "blending")
|
||||
{
|
||||
m_nElement = ELEMENT_PASS_BLEND;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nElement = ELEMENT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
void FoundAttribute(const string& name, const string& value)
|
||||
{
|
||||
//MessageBox(NULL, string(name + "\n" + value).c_str(), "FoundAttribute", MB_OK);
|
||||
switch (m_nElement)
|
||||
{
|
||||
case ELEMENT_FONT:
|
||||
if (name == "path")
|
||||
{
|
||||
m_strFontPath = value;
|
||||
}
|
||||
else if (name == "w")
|
||||
{
|
||||
m_FontTexSize.x = (long)atof(value.c_str());
|
||||
}
|
||||
else if (name == "h")
|
||||
{
|
||||
m_FontTexSize.y = (long)atof(value.c_str());
|
||||
}
|
||||
else if (name == "widthslots")
|
||||
{
|
||||
m_SlotSizes.x = (int)atoi(value.c_str());
|
||||
}
|
||||
else if (name == "heightslots")
|
||||
{
|
||||
m_SlotSizes.y = (int)atoi(value.c_str());
|
||||
}
|
||||
else if (name == "sizeratio")
|
||||
{
|
||||
m_SizeRatio = static_cast<float>(atof(value.c_str()));
|
||||
}
|
||||
else if (name == "smooth")
|
||||
{
|
||||
if (value == "blur")
|
||||
{
|
||||
m_FontSmoothMethod = FONT_SMOOTH_BLUR;
|
||||
}
|
||||
else if (value == "supersample")
|
||||
{
|
||||
m_FontSmoothMethod = FONT_SMOOTH_SUPERSAMPLE;
|
||||
}
|
||||
else if (value == "none")
|
||||
{
|
||||
m_FontSmoothMethod = FONT_SMOOTH_NONE;
|
||||
}
|
||||
}
|
||||
else if (name == "smooth_amount")
|
||||
{
|
||||
m_FontSmoothAmount = (long)atof(value.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case ELEMENT_EFFECT:
|
||||
if (name == "name")
|
||||
{
|
||||
if (value == "default")
|
||||
{
|
||||
m_pEffect = m_pFont->GetDefaultEffect();
|
||||
m_pEffect->ClearPasses();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pEffect = m_pFont->AddEffect(value.c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ELEMENT_EFFECTFILE:
|
||||
if (name == "path")
|
||||
{
|
||||
m_strFontEffectPath = value;
|
||||
}
|
||||
break;
|
||||
|
||||
case ELEMENT_PASS_COLOR:
|
||||
if (!m_pPass)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (name == "r")
|
||||
{
|
||||
m_pPass->m_color.r = (uint8)((float)atof(value.c_str()) * 255.0f);
|
||||
}
|
||||
else if (name == "g")
|
||||
{
|
||||
m_pPass->m_color.g = (uint8)((float)atof(value.c_str()) * 255.0f);
|
||||
}
|
||||
else if (name == "b")
|
||||
{
|
||||
m_pPass->m_color.b = (uint8)((float)atof(value.c_str()) * 255.0f);
|
||||
}
|
||||
else if (name == "a")
|
||||
{
|
||||
m_pPass->m_color.a = (uint8)((float)atof(value.c_str()) * 255.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
case ELEMENT_PASS_POSOFFSET:
|
||||
if (!m_pPass)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (name == "x")
|
||||
{
|
||||
m_pPass->m_posOffset.x = (float)atoi(value.c_str());
|
||||
}
|
||||
else if (name == "y")
|
||||
{
|
||||
m_pPass->m_posOffset.y = (float)atoi(value.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case ELEMENT_PASS_BLEND:
|
||||
if (!m_pPass)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (name == "src")
|
||||
{
|
||||
m_pPass->m_blendSrc = GetBlendModeFromString(value, false);
|
||||
}
|
||||
else if (name == "dst")
|
||||
{
|
||||
m_pPass->m_blendDest = GetBlendModeFromString(value, true);
|
||||
}
|
||||
else if (name == "type")
|
||||
{
|
||||
if (value == "modulate")
|
||||
{
|
||||
m_pPass->m_blendSrc = GS_BLSRC_SRCALPHA;
|
||||
m_pPass->m_blendDest = GS_BLDST_ONEMINUSSRCALPHA;
|
||||
}
|
||||
else if (value == "additive")
|
||||
{
|
||||
m_pPass->m_blendSrc = GS_BLSRC_SRCALPHA;
|
||||
m_pPass->m_blendDest = GS_BLDST_ONE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case ELEMENT_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
CFFont* m_pFont;
|
||||
|
||||
unsigned long m_nElement;
|
||||
|
||||
CFFont::SEffect* m_pEffect;
|
||||
CFFont::SRenderingPass* m_pPass;
|
||||
|
||||
string m_strFontPath;
|
||||
string m_strFontEffectPath;
|
||||
vector2l m_FontTexSize;
|
||||
Vec2i m_SlotSizes;
|
||||
float m_SizeRatio = IFFontConstants::defaultSizeRatio;
|
||||
|
||||
int m_FontSmoothMethod;
|
||||
int m_FontSmoothAmount;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Main loading function
|
||||
bool CFFont::Load(const char* pXMLFile)
|
||||
{
|
||||
m_curPath = "";
|
||||
if (pXMLFile)
|
||||
{
|
||||
m_curPath = PathUtil::GetPath(pXMLFile);
|
||||
}
|
||||
|
||||
XmlNodeRef root = GetISystem()->LoadXmlFromFile(pXMLFile);
|
||||
if (!root)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CXmlFontShader xmlfs(this);
|
||||
xmlfs.ScanXmlNodesRecursively(root);
|
||||
|
||||
// if this was not a valid font XML file then return false
|
||||
if (!m_pFontTexture || !m_pFontBuffer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// if there was a font effect file then parse that for effects
|
||||
if (!xmlfs.m_strFontEffectPath.empty())
|
||||
{
|
||||
XmlNodeRef fontEffectRoot = GetISystem()->LoadXmlFromFile(xmlfs.m_strFontEffectPath.c_str());
|
||||
if (!fontEffectRoot)
|
||||
{
|
||||
AZ_Warning("Font", false, "Error parsing font file %s, 'effectfile' pathname %s could not be found.",
|
||||
pXMLFile, xmlfs.m_strFontEffectPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_effects.size() > 1 || (m_effects.size() == 1 && (m_effects[0].m_name != "default" || m_effects[0].m_passes.size() > 1)))
|
||||
{
|
||||
AZ_Warning("Font", false, "Error parsing font file %s, 'effectfile' and 'effect' cannot both be used in the same font file.",
|
||||
pXMLFile);
|
||||
m_effects.clear();
|
||||
}
|
||||
|
||||
// parse the font effects file, adding to this font object
|
||||
CXmlFontShader xmlfsEffect(this);
|
||||
xmlfsEffect.ScanXmlNodesRecursively(fontEffectRoot);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,398 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
//
|
||||
// Purpose:
|
||||
// - Render a glyph outline into a bitmap using FreeType 2
|
||||
|
||||
#include "CryFont_precompiled.h"
|
||||
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#include "FontRenderer.h"
|
||||
|
||||
#include <freetype/ftoutln.h>
|
||||
#include <freetype/ftglyph.h>
|
||||
#include <freetype/ftimage.h>
|
||||
|
||||
#include <AzCore/Casting/lossy_cast.h>
|
||||
|
||||
// Sizes are defined in in 26.6 fixed float format (TT_F26Dot6), where
|
||||
// 1 unit is 1/64 of a pixel.
|
||||
static const int fractionalPixelUnits = 64;
|
||||
|
||||
namespace
|
||||
{
|
||||
FT_Int32 GetLoadFlags(CFFont::HintBehavior hintBehavior)
|
||||
{
|
||||
switch (hintBehavior)
|
||||
{
|
||||
case CFFont::HintBehavior::NoHinting:
|
||||
{
|
||||
return FT_LOAD_NO_HINTING;
|
||||
break;
|
||||
}
|
||||
case CFFont::HintBehavior::AutoHint:
|
||||
{
|
||||
return FT_LOAD_FORCE_AUTOHINT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FT_LOAD_DEFAULT;
|
||||
}
|
||||
|
||||
FT_Int32 GetLoadTarget(CFFont::HintStyle hintStyle)
|
||||
{
|
||||
if (hintStyle == CFFont::HintStyle::Light)
|
||||
{
|
||||
return FT_LOAD_TARGET_LIGHT;
|
||||
}
|
||||
|
||||
return FT_LOAD_TARGET_NORMAL;
|
||||
}
|
||||
|
||||
FT_Render_Mode GetRenderMode(CFFont::HintStyle hintStyle)
|
||||
{
|
||||
// We use the hint style to drive the render mode also. These should
|
||||
// usually be correlated with each other for best results, even though
|
||||
// they could technically be different.
|
||||
if (hintStyle == CFFont::HintStyle::Light)
|
||||
{
|
||||
return FT_RENDER_MODE_LIGHT;
|
||||
}
|
||||
|
||||
return FT_RENDER_MODE_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CFontRenderer::CFontRenderer()
|
||||
: m_pLibrary(0)
|
||||
, m_pFace(0)
|
||||
, m_pGlyph(0)
|
||||
, m_fSizeRatio(IFFontConstants::defaultSizeRatio)
|
||||
, m_pEncoding(FONT_ENCODING_UNICODE)
|
||||
, m_iGlyphBitmapWidth(0)
|
||||
, m_iGlyphBitmapHeight(0)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CFontRenderer::~CFontRenderer()
|
||||
{
|
||||
FT_Done_Face(m_pFace);
|
||||
;
|
||||
FT_Done_FreeType(m_pLibrary);
|
||||
m_pFace = NULL;
|
||||
m_pLibrary = NULL;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontRenderer::LoadFromFile(const string& szFileName)
|
||||
{
|
||||
int iError = FT_Init_FreeType(&m_pLibrary);
|
||||
|
||||
if (iError)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (m_pFace)
|
||||
{
|
||||
FT_Done_Face(m_pFace);
|
||||
m_pFace = 0;
|
||||
}
|
||||
|
||||
iError = FT_New_Face(m_pLibrary, szFileName.c_str(), 0, &m_pFace);
|
||||
|
||||
if (iError)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetEncoding(FONT_ENCODING_UNICODE);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontRenderer::LoadFromMemory(unsigned char* pBuffer, int iBufferSize)
|
||||
{
|
||||
int iError = FT_Init_FreeType(&m_pLibrary);
|
||||
|
||||
if (iError)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (m_pFace)
|
||||
{
|
||||
FT_Done_Face(m_pFace);
|
||||
m_pFace = 0;
|
||||
}
|
||||
iError = FT_New_Memory_Face(m_pLibrary, pBuffer, iBufferSize, 0, &m_pFace);
|
||||
|
||||
if (iError)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetEncoding(FONT_ENCODING_UNICODE);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontRenderer::Release()
|
||||
{
|
||||
FT_Done_Face(m_pFace);
|
||||
;
|
||||
FT_Done_FreeType(m_pLibrary);
|
||||
m_pFace = NULL;
|
||||
m_pLibrary = NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontRenderer::SetGlyphBitmapSize(int iWidth, int iHeight, float sizeRatio)
|
||||
{
|
||||
m_iGlyphBitmapWidth = iWidth;
|
||||
m_iGlyphBitmapHeight = iHeight;
|
||||
|
||||
// Assign the given scale for texture slots as long as its positive
|
||||
m_fSizeRatio = sizeRatio > 0.0f ? sizeRatio : m_fSizeRatio;
|
||||
|
||||
FT_Set_Pixel_Sizes(m_pFace, (int)(m_iGlyphBitmapWidth * m_fSizeRatio), (int)(m_iGlyphBitmapHeight * m_fSizeRatio));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontRenderer::GetGlyphBitmapSize(int* pWidth, int* pHeight)
|
||||
{
|
||||
if (pWidth)
|
||||
{
|
||||
*pWidth = m_iGlyphBitmapWidth;
|
||||
}
|
||||
|
||||
if (pHeight)
|
||||
{
|
||||
*pHeight = m_iGlyphBitmapHeight;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontRenderer::SetEncoding(FT_Encoding pEncoding)
|
||||
{
|
||||
if (FT_Select_Charmap(m_pFace, pEncoding))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontRenderer::GetGlyph(CGlyphBitmap* pGlyphBitmap, int* iHoriAdvance, uint8* iGlyphWidth, uint8* iGlyphHeight, AZ::s32& iCharOffsetX, AZ::s32& iCharOffsetY, int iX, int iY, int iCharCode, const CFFont::FontHintParams& fontHintParams)
|
||||
{
|
||||
FT_Int32 loadFlags = GetLoadFlags(fontHintParams.hintBehavior);
|
||||
loadFlags |= GetLoadTarget(fontHintParams.hintStyle);
|
||||
|
||||
int iError = FT_Load_Char(m_pFace, iCharCode, loadFlags);
|
||||
|
||||
if (iError)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
FT_Render_Mode renderMode = GetRenderMode(fontHintParams.hintStyle);
|
||||
|
||||
m_pGlyph = m_pFace->glyph;
|
||||
|
||||
iError = FT_Render_Glyph(m_pGlyph, renderMode);
|
||||
|
||||
if (iError)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (iHoriAdvance)
|
||||
{
|
||||
*iHoriAdvance = m_pGlyph->metrics.horiAdvance / fractionalPixelUnits;
|
||||
}
|
||||
|
||||
if (iGlyphWidth)
|
||||
{
|
||||
*iGlyphWidth = m_pGlyph->bitmap.width;
|
||||
}
|
||||
|
||||
if (iGlyphHeight)
|
||||
{
|
||||
*iGlyphHeight = m_pGlyph->bitmap.rows;
|
||||
}
|
||||
|
||||
unsigned char* pBuffer = pGlyphBitmap->GetBuffer();
|
||||
AZ_Assert(pBuffer, "CGlyphBitmap: bad buffer");
|
||||
|
||||
uint32 dwGlyphWidth = pGlyphBitmap->GetWidth();
|
||||
iCharOffsetX = m_pGlyph->bitmap_left;
|
||||
iCharOffsetY = (static_cast<AZ::s32>(round(m_iGlyphBitmapHeight * m_fSizeRatio)) - m_pGlyph->bitmap_top);
|
||||
|
||||
const int textureSlotBufferWidth = pGlyphBitmap->GetWidth();
|
||||
const int textureSlotBufferHeight = pGlyphBitmap->GetHeight();
|
||||
|
||||
// might happen if font characters are too big or cache dimenstions in font.xml is too small "<font path="VeraMono.ttf" w="320" h="368"/>"
|
||||
const bool charWidthFits = iX + m_pGlyph->bitmap.width <= textureSlotBufferWidth;
|
||||
const bool charHeightFits = iY + m_pGlyph->bitmap.rows <= textureSlotBufferHeight;
|
||||
const bool charFitsInSlot = charWidthFits && charHeightFits;
|
||||
AZ_Error("Font", charFitsInSlot, "Character code %d doesn't fit in font texture; check 'sizeRatio' attribute in font XML or adjust this character's sizing in the font.", iCharCode);
|
||||
|
||||
// Since we might be re-rendering/overwriting a glyph that already exists
|
||||
// in the font texture, clear the contents of this particular slot so no
|
||||
// artifacts of the previous glyph remain.
|
||||
pGlyphBitmap->Clear();
|
||||
|
||||
// Restrict iteration to smallest of either the texture slot or glyph
|
||||
// bitmap buffer ranges
|
||||
const int bufferMaxIterWidth = AZStd::GetMin<int>(textureSlotBufferWidth, m_pGlyph->bitmap.width);
|
||||
const int bufferMaxIterHeight = AZStd::GetMin<int>(textureSlotBufferHeight, m_pGlyph->bitmap.rows);
|
||||
|
||||
for (int i = 0; i < bufferMaxIterHeight; i++)
|
||||
{
|
||||
int iNewY = i + iY;
|
||||
|
||||
for (int j = 0; j < bufferMaxIterWidth; j++)
|
||||
{
|
||||
unsigned char cColor = m_pGlyph->bitmap.buffer[(i * m_pGlyph->bitmap.width) + j];
|
||||
int iOffset = iNewY * dwGlyphWidth + iX + j;
|
||||
|
||||
if (iOffset >= (int)dwGlyphWidth * m_iGlyphBitmapHeight)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
pBuffer[iOffset] = cColor;
|
||||
// pBuffer[iOffset] = cColor/2+32; // debug - visualize character in a block
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CFontRenderer::GetGlyphScaled([[maybe_unused]] CGlyphBitmap* pGlyphBitmap, [[maybe_unused]] int* iGlyphWidth, [[maybe_unused]] int* iGlyphHeight, [[maybe_unused]] int iX, [[maybe_unused]] int iY, [[maybe_unused]] float fScaleX, [[maybe_unused]] float fScaleY, [[maybe_unused]] int iCharCode)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Vec2 CFontRenderer::GetKerning(uint32_t leftGlyph, uint32_t rightGlyph)
|
||||
{
|
||||
FT_Vector kerningOffsets;
|
||||
kerningOffsets.x = kerningOffsets.y = 0;
|
||||
|
||||
if (FT_HAS_KERNING(m_pFace))
|
||||
{
|
||||
const FT_UInt leftGlyphIndex = FT_Get_Char_Index(m_pFace, leftGlyph);
|
||||
const FT_UInt rightGlyphIndex = FT_Get_Char_Index(m_pFace, rightGlyph);
|
||||
|
||||
[[maybe_unused]] FT_Error ftError = FT_Get_Kerning(m_pFace, leftGlyphIndex, rightGlyphIndex, FT_KERNING_DEFAULT, &kerningOffsets);
|
||||
|
||||
#if !defined(_RELEASE)
|
||||
if (0 != ftError)
|
||||
{
|
||||
string warnMsg;
|
||||
warnMsg.Format("FT_Get_Kerning returned %d", ftError);
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, warnMsg.c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return Vec2(azlossy_cast<float>(kerningOffsets.x / fractionalPixelUnits), azlossy_cast<float>(kerningOffsets.y / fractionalPixelUnits));
|
||||
}
|
||||
|
||||
float CFontRenderer::GetAscenderToHeightRatio()
|
||||
{
|
||||
return (static_cast<float>(m_pFace->ascender) / static_cast<float>(m_pFace->height));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
int CFontRenderer::FT_GetIndex(int iCharCode)
|
||||
{
|
||||
if (iCharCode < 256)
|
||||
{
|
||||
int iIndex = 0;
|
||||
int iUnicode;
|
||||
|
||||
// try unicode
|
||||
for (int i = 0; i < m_pFace->num_charmaps; i++)
|
||||
{
|
||||
if ((m_pFace->charmaps[i]->platform_id == 3) && (m_pFace->charmaps[i]->encoding_id == 1))
|
||||
{
|
||||
iUnicode = i;
|
||||
|
||||
FT_Set_Charmap(m_pFace, m_pFace->charmaps[i]);
|
||||
|
||||
iIndex = FT_Get_Char_Index(m_pFace, iCharCode);
|
||||
|
||||
// not unicode, try ascii
|
||||
if (iIndex == 0)
|
||||
{
|
||||
for (int i = 0; i < m_pFace->num_charmaps; i++)
|
||||
{
|
||||
if ((m_pFace->charmaps[i]->platform_id == 0) && (m_pFace->charmaps[i]->encoding_id == 0))
|
||||
{
|
||||
FT_Set_Charmap(m_pFace, m_pFace->charmaps[i]);
|
||||
|
||||
iIndex = FT_Get_Char_Index(m_pFace, iCharCode);
|
||||
|
||||
// not ascii either, reuse unicode default "missing char"
|
||||
if (iIndex == 0)
|
||||
{
|
||||
FT_Set_Charmap(m_pFace, m_pFace->charmaps[iUnicode]);
|
||||
|
||||
return FT_Get_Char_Index(m_pFace, iCharCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return iIndex;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < m_pFace->num_charmaps; i++)
|
||||
{
|
||||
if ((m_pFace->charmaps[i]->platform_id == 3) && (m_pFace->charmaps[i]->encoding_id == 1))
|
||||
{
|
||||
FT_Set_Charmap(m_pFace, m_pFace->charmaps[i]);
|
||||
|
||||
return FT_Get_Char_Index(m_pFace, iCharCode);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
#endif // #if !defined(USE_NULLFONT_ALWAYS)
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Render a glyph outline into a bitmap using FreeType 2
|
||||
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#ifndef CRYINCLUDE_CRYFONT_FONTRENDERER_H
|
||||
#define CRYINCLUDE_CRYFONT_FONTRENDERER_H
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
#include "GlyphBitmap.h"
|
||||
#include "FFont.h"
|
||||
#include <ft2build.h>
|
||||
#pragma push_macro("generic")
|
||||
#define generic GenericFromFreeTypeLibrary
|
||||
#include <freetype/freetype.h>
|
||||
#undef generic
|
||||
#pragma pop_macro("generic")
|
||||
|
||||
|
||||
// Corresponds to the Unicode character set. This value covers all versions of the Unicode repertoire,
|
||||
// including ASCII and Latin-1. Most fonts include a Unicode charmap, but not all of them.
|
||||
#define FONT_ENCODING_UNICODE (FT_ENCODING_UNICODE)
|
||||
|
||||
// Corresponds to the Microsoft Symbol encoding, used to encode mathematical symbols in the 32..255 character code range.
|
||||
// For more information, see `http://www.ceviz.net/symbol.htm'.
|
||||
#define FONT_ENCODING_SYMBOL (FT_ENCODING_MS_SYMBOL)
|
||||
|
||||
// Corresponds to Microsoft's Japanese SJIS encoding.
|
||||
// More info at `http://langsupport.japanreference.com/encoding.shtml'. See note on multi-byte encodings below.
|
||||
#define FONT_ENCODING_SJIS (FT_ENCODING_MS_SJIS)
|
||||
|
||||
// Corresponds to the encoding system for Simplified Chinese, as used in China. Only found in some TrueType fonts.
|
||||
#define FONT_ENCODING_GB2312 (FT_ENCODING_MS_GB2312)
|
||||
|
||||
// Corresponds to the encoding system for Traditional Chinese, as used in Taiwan and Hong Kong. Only found in some TrueType fonts.
|
||||
#define FONT_ENCODING_BIG5 (FT_ENCODING_MS_BIG5)
|
||||
|
||||
// Corresponds to the Korean encoding system known as Wansung.
|
||||
// This is a Microsoft encoding that is only found in some TrueType fonts.
|
||||
// For more information, see `http://www.microsoft.com/typography/unicode/949.txt'.
|
||||
#define FONT_ENCODING_WANSUNG (FT_ENCODING_MS_WANSUNG)
|
||||
|
||||
// The Korean standard character set (KS C-5601-1992), which corresponds to Windows code page 1361.
|
||||
// This character set includes all possible Hangeul character combinations. Only found on some rare TrueType fonts.
|
||||
#define FONT_ENCODING_JOHAB (FT_ENCODING_MS_JOHAB)
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
class CFontRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
CFontRenderer();
|
||||
~CFontRenderer();
|
||||
|
||||
int LoadFromFile(const string& szFileName);
|
||||
int LoadFromMemory(unsigned char* pBuffer, int iBufferSize);
|
||||
int Release();
|
||||
|
||||
int SetGlyphBitmapSize(int iWidth, int iHeight, float sizeRatio);
|
||||
int GetGlyphBitmapSize(int* pWidth, int* pHeight);
|
||||
|
||||
int SetSizeRatio(float fSizeRatio) { m_fSizeRatio = fSizeRatio; return 1; };
|
||||
float GetSizeRatio() { return m_fSizeRatio; };
|
||||
|
||||
int SetEncoding(FT_Encoding pEncoding);
|
||||
FT_Encoding GetEncoding() { return m_pEncoding; };
|
||||
|
||||
//! Populates the given pGlyphBitmap's buffer from the FreeType bitmap buffer
|
||||
//! \param iCharCode Used as a character index to retrieve the FreeType glyph and it's associated bitmap buffer for the character
|
||||
//! \param pGlyphBitmap The FreeType glyph buffer is essentially copied into this CGlyphBitmap buffer
|
||||
int GetGlyph(CGlyphBitmap* pGlyphBitmap, int* iHoriAdvance, uint8* iGlyphWidth, uint8* iGlyphHeight, AZ::s32& iCharOffsetX, AZ::s32& iCharOffsetY, int iX, int iY, int iCharCode, const CFFont::FontHintParams& glyphFlags = CFFont::FontHintParams());
|
||||
int GetGlyphScaled(CGlyphBitmap* pGlyphBitmap, int* iGlyphWidth, int* iGlyphHeight, int iX, int iY, float fScaleX, float fScaleY, int iCharCode);
|
||||
|
||||
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const {}
|
||||
|
||||
bool GetMonospaced() const { return FT_IS_FIXED_WIDTH(m_pFace) != 0; }
|
||||
|
||||
Vec2 GetKerning(uint32_t leftGlyph, uint32_t rightGlyph);
|
||||
|
||||
float GetAscenderToHeightRatio();
|
||||
|
||||
private:
|
||||
|
||||
FT_Library m_pLibrary;
|
||||
FT_Face m_pFace;
|
||||
FT_GlyphSlot m_pGlyph;
|
||||
float m_fSizeRatio;
|
||||
|
||||
FT_Encoding m_pEncoding;
|
||||
|
||||
int m_iGlyphBitmapWidth;
|
||||
int m_iGlyphBitmapHeight;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_CRYFONT_FONTRENDERER_H
|
||||
|
||||
#endif // #if !defined(USE_NULLFONT_ALWAYS)
|
||||
@@ -1,633 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Purpose:
|
||||
// - Create and update a texture with the most recently used glyphs
|
||||
|
||||
#include "CryFont_precompiled.h"
|
||||
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#include "FontTexture.h"
|
||||
#include "UnicodeIterator.h"
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#undef GetCharWidth
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CFontTexture::CFontTexture()
|
||||
: m_wSlotUsage(1)
|
||||
, m_iWidth(0)
|
||||
, m_iHeight(0)
|
||||
, m_fInvWidth(0.0f)
|
||||
, m_fInvHeight(0.0f)
|
||||
, m_iCellWidth(0)
|
||||
, m_iCellHeight(0)
|
||||
, m_fTextureCellWidth(0)
|
||||
, m_fTextureCellHeight(0)
|
||||
, m_iWidthCellCount(0)
|
||||
, m_iHeightCellCount(0)
|
||||
, m_nTextureSlotCount(0)
|
||||
, m_pBuffer(0)
|
||||
, m_iSmoothMethod(FONT_SMOOTH_NONE)
|
||||
, m_iSmoothAmount(FONT_SMOOTH_AMOUNT_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CFontTexture::~CFontTexture()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontTexture::CreateFromFile(const string& szFileName, int iWidth, int iHeight, int iSmoothMethod, int iSmoothAmount, int iWidthCellCount, int iHeightCellCount)
|
||||
{
|
||||
if (!m_pGlyphCache.LoadFontFromFile(szFileName))
|
||||
{
|
||||
Release();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!Create(iWidth, iHeight, iSmoothMethod, iSmoothAmount, iWidthCellCount, iHeightCellCount))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontTexture::CreateFromMemory(unsigned char* pFileData, int iDataSize, int iWidth, int iHeight, int iSmoothMethod, int iSmoothAmount, int iWidthCellCount, int iHeightCellCount, float sizeRatio)
|
||||
{
|
||||
if (!m_pGlyphCache.LoadFontFromMemory(pFileData, iDataSize))
|
||||
{
|
||||
Release();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!Create(iWidth, iHeight, iSmoothMethod, iSmoothAmount, iWidthCellCount, iHeightCellCount, sizeRatio))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontTexture::Create(int iWidth, int iHeight, int iSmoothMethod, int iSmoothAmount, int iWidthCellCount, int iHeightCellCount, float sizeRatio)
|
||||
{
|
||||
m_pBuffer = new FONT_TEXTURE_TYPE[iWidth * iHeight];
|
||||
if (!m_pBuffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(m_pBuffer, 0, iWidth * iHeight * sizeof(FONT_TEXTURE_TYPE));
|
||||
|
||||
if (!(iWidthCellCount * iHeightCellCount))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_iWidth = iWidth;
|
||||
m_iHeight = iHeight;
|
||||
m_fInvWidth = 1.0f / (float)iWidth;
|
||||
m_fInvHeight = 1.0f / (float)iHeight;
|
||||
|
||||
m_iWidthCellCount = iWidthCellCount;
|
||||
m_iHeightCellCount = iHeightCellCount;
|
||||
m_nTextureSlotCount = m_iWidthCellCount * m_iHeightCellCount;
|
||||
|
||||
m_iSmoothMethod = iSmoothMethod;
|
||||
m_iSmoothAmount = iSmoothAmount;
|
||||
|
||||
m_iCellWidth = m_iWidth / m_iWidthCellCount;
|
||||
m_iCellHeight = m_iHeight / m_iHeightCellCount;
|
||||
|
||||
m_fTextureCellWidth = m_iCellWidth * m_fInvWidth;
|
||||
m_fTextureCellHeight = m_iCellHeight * m_fInvHeight;
|
||||
|
||||
if (!m_pGlyphCache.Create(FONT_GLYPH_CACHE_SIZE, m_iCellWidth, m_iCellHeight, iSmoothMethod, iSmoothAmount, sizeRatio))
|
||||
{
|
||||
Release();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!CreateSlotList(m_nTextureSlotCount))
|
||||
{
|
||||
Release();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontTexture::Release()
|
||||
{
|
||||
delete[] m_pBuffer;
|
||||
m_pBuffer = 0;
|
||||
|
||||
ReleaseSlotList();
|
||||
|
||||
m_pSlotTable.clear();
|
||||
|
||||
m_pGlyphCache.Release();
|
||||
|
||||
m_iWidthCellCount = 0;
|
||||
m_iHeightCellCount = 0;
|
||||
m_nTextureSlotCount = 0;
|
||||
|
||||
m_iWidth = 0;
|
||||
m_iHeight = 0;
|
||||
m_fInvWidth = 0.0f;
|
||||
m_fInvHeight = 0.0f;
|
||||
|
||||
m_iCellWidth = 0;
|
||||
m_iCellHeight = 0;
|
||||
|
||||
m_iSmoothMethod = 0;
|
||||
m_iSmoothAmount = 0;
|
||||
|
||||
m_fTextureCellWidth = 0.0f;
|
||||
m_fTextureCellHeight = 0.0f;
|
||||
|
||||
m_wSlotUsage = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
uint32 CFontTexture::GetSlotChar(int iSlot) const
|
||||
{
|
||||
return m_pSlotList[iSlot]->cCurrentChar;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CTextureSlot* CFontTexture::GetCharSlot(uint32 cChar, const Vec2i& glyphSize)
|
||||
{
|
||||
CryFont::FontTexture::CTextureSlotKey slotKey = GetTextureSlotKey(cChar, glyphSize);
|
||||
CTextureSlotTableItor pItor = m_pSlotTable.find(slotKey);
|
||||
|
||||
if (pItor != m_pSlotTable.end())
|
||||
{
|
||||
return pItor->second;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CTextureSlot* CFontTexture::GetLRUSlot()
|
||||
{
|
||||
uint16 wMaxSlotAge = 0;
|
||||
CTextureSlot* pLRUSlot = 0;
|
||||
CTextureSlot* pSlot;
|
||||
|
||||
CTextureSlotListItor pItor = m_pSlotList.begin();
|
||||
|
||||
while (pItor != m_pSlotList.end())
|
||||
{
|
||||
pSlot = *pItor;
|
||||
|
||||
if (pSlot->wSlotUsage == 0)
|
||||
{
|
||||
return pSlot;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16 slotAge = m_wSlotUsage - pSlot->wSlotUsage;
|
||||
if (slotAge > wMaxSlotAge)
|
||||
{
|
||||
pLRUSlot = pSlot;
|
||||
wMaxSlotAge = slotAge;
|
||||
}
|
||||
}
|
||||
|
||||
++pItor;
|
||||
}
|
||||
|
||||
return pLRUSlot;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CTextureSlot* CFontTexture::GetMRUSlot()
|
||||
{
|
||||
uint16 wMinSlotAge = 0xFFFF;
|
||||
CTextureSlot* pMRUSlot = 0;
|
||||
CTextureSlot* pSlot;
|
||||
|
||||
CTextureSlotListItor pItor = m_pSlotList.begin();
|
||||
|
||||
while (pItor != m_pSlotList.end())
|
||||
{
|
||||
pSlot = *pItor;
|
||||
|
||||
if (pSlot->wSlotUsage != 0)
|
||||
{
|
||||
uint16 slotAge = m_wSlotUsage - pSlot->wSlotUsage;
|
||||
if (slotAge > wMinSlotAge)
|
||||
{
|
||||
pMRUSlot = pSlot;
|
||||
wMinSlotAge = slotAge;
|
||||
}
|
||||
}
|
||||
|
||||
++pItor;
|
||||
}
|
||||
|
||||
return pMRUSlot;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontTexture::PreCacheString(const char* szString, int* pUpdated, float sizeRatio, const Vec2i& glyphSize, const CFFont::FontHintParams& fontHintParams)
|
||||
{
|
||||
Vec2i clampedGlyphSize = ClampGlyphSize(glyphSize, m_iCellWidth, m_iCellHeight);
|
||||
|
||||
uint16 wSlotUsage = m_wSlotUsage++;
|
||||
int iUpdated = 0;
|
||||
|
||||
uint32 cChar;
|
||||
for (Unicode::CIterator<const char*, false> it(szString); *it; ++it)
|
||||
{
|
||||
cChar = *it;
|
||||
CTextureSlot* pSlot = GetCharSlot(cChar, clampedGlyphSize);
|
||||
|
||||
if (!pSlot)
|
||||
{
|
||||
pSlot = GetLRUSlot();
|
||||
|
||||
if (!pSlot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!UpdateSlot(pSlot->iTextureSlot, wSlotUsage, cChar, sizeRatio, clampedGlyphSize, fontHintParams))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
++iUpdated;
|
||||
}
|
||||
else
|
||||
{
|
||||
pSlot->wSlotUsage = wSlotUsage;
|
||||
}
|
||||
}
|
||||
|
||||
if (pUpdated)
|
||||
{
|
||||
*pUpdated = iUpdated;
|
||||
}
|
||||
|
||||
if (iUpdated)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
void CFontTexture::GetTextureCoord(CTextureSlot* pSlot, float texCoords[4],
|
||||
int& iCharSizeX, int& iCharSizeY, int& iCharOffsetX, int& iCharOffsetY,
|
||||
const Vec2i& glyphSize) const
|
||||
{
|
||||
if (!pSlot)
|
||||
{
|
||||
return; // expected behavior
|
||||
}
|
||||
|
||||
// Re-rendered glyphs are stored at smaller sizes than glyphs rendered at
|
||||
// the (maximum) font texture slot resolution. We scale the returned width
|
||||
// and height of the (actual) rendered glyph sizes so its transparent to
|
||||
// callers that the glyph is actually smaller (from being re-rendered).
|
||||
const float requestSizeWidthScale = AZ::GetMin<float>(1.0f, GetRequestSizeWidthScale(glyphSize));
|
||||
const float requestSizeHeightScale = AZ::GetMin<float>(1.0f, GetRequestSizeHeightScale(glyphSize));
|
||||
const float invRequestSizeWidthScale = 1.0f / requestSizeWidthScale;
|
||||
const float invRequestSizeHeightScale = 1.0f / requestSizeHeightScale;
|
||||
|
||||
// The inverse scale grows as the glyph size decreases. Once the glyph size
|
||||
// reaches the font texture's max slot dimensions, we cap width/height scale
|
||||
// since the text draw context will apply normal (as opposed to re-rendered)
|
||||
// scaling.
|
||||
int iChWidth = static_cast<int>(pSlot->iCharWidth * invRequestSizeWidthScale);
|
||||
int iChHeight = static_cast<int>(pSlot->iCharHeight * invRequestSizeHeightScale);
|
||||
|
||||
float slotCoord0 = pSlot->vTexCoord[0];
|
||||
float slotCoord1 = pSlot->vTexCoord[1];
|
||||
texCoords[0] = slotCoord0 - m_fInvWidth; // extra pixel for nicer bilinear filter
|
||||
texCoords[1] = slotCoord1 - m_fInvHeight; // extra pixel for nicer bilinear filter
|
||||
|
||||
// UV coordinates also must be scaled relative to the re-rendered glyph size
|
||||
// as well. Width scale must be capped at 1.0f since glyph can't grow
|
||||
// beyond the slot's resolution.
|
||||
texCoords[2] = slotCoord0 + (((float)iChWidth * m_fInvWidth) * requestSizeWidthScale);
|
||||
texCoords[3] = slotCoord1 + (((float)iChHeight * m_fInvHeight) * requestSizeHeightScale);
|
||||
|
||||
iCharSizeX = iChWidth + 1; // extra pixel for nicer bilinear filter
|
||||
iCharSizeY = iChHeight + 1; // extra pixel for nicer bilinear filter
|
||||
|
||||
// Offsets are scaled accordingly when the rendered glyph size is smaller
|
||||
// than the glyph/slot dimensions, but otherwise we expect the text draw
|
||||
// context to apply scaling beyond that.
|
||||
iCharOffsetX = static_cast<int>(pSlot->iCharOffsetX * invRequestSizeWidthScale);
|
||||
iCharOffsetY = static_cast<int>(pSlot->iCharOffsetY * invRequestSizeHeightScale);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontTexture::GetCharacterWidth(uint32 cChar) const
|
||||
{
|
||||
CTextureSlotTableItorConst pItor = m_pSlotTable.find(GetTextureSlotKey(cChar));
|
||||
|
||||
if (pItor == m_pSlotTable.end())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const CTextureSlot& rSlot = *pItor->second;
|
||||
|
||||
// For proportional fonts, add one pixel of spacing for aesthetic reasons
|
||||
int proportionalOffset = GetMonospaced() ? 0 : 1;
|
||||
|
||||
return rSlot.iCharWidth + proportionalOffset;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontTexture::GetHorizontalAdvance(uint32 cChar, const Vec2i& glyphSize) const
|
||||
{
|
||||
CTextureSlotTableItorConst pItor = m_pSlotTable.find(GetTextureSlotKey(cChar, glyphSize));
|
||||
|
||||
if (pItor == m_pSlotTable.end())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const CTextureSlot& rSlot = *pItor->second;
|
||||
|
||||
// Re-rendered glyphs are stored at smaller sizes than glyphs rendered at
|
||||
// the (maximum) font texture slot resolution. We scale the returned width
|
||||
// and height of the (actual) rendered glyph sizes so its transparent to
|
||||
// callers that the glyph is actually smaller (from being re-rendered).
|
||||
const float requestSizeWidthScale = GetRequestSizeWidthScale(glyphSize);
|
||||
const float invRequestSizeWidthScale = 1.0f / requestSizeWidthScale;
|
||||
|
||||
// Only multiply by 1.0f when glyphsize is greater than cell width because we assume that callers
|
||||
// will use the font draw text context to scale the value appropriately.
|
||||
return static_cast<int>(rSlot.iHoriAdvance * AZ::GetMax<float>(1.0f, invRequestSizeWidthScale));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
int CFontTexture::GetCharHeightByChar(wchar_t cChar)
|
||||
{
|
||||
CTextureSlotTableItor pItor = m_pSlotTable.find(cChar);
|
||||
|
||||
if (pItor != m_pSlotTable.end())
|
||||
{
|
||||
return pItor->second->iCharHeight;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontTexture::WriteToFile([[maybe_unused]] const string& szFileName)
|
||||
{
|
||||
#ifdef WIN32
|
||||
AZ::IO::FileIOStream outputFile(szFileName.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeBinary);
|
||||
|
||||
if (!outputFile.IsOpen())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BITMAPFILEHEADER pHeader;
|
||||
BITMAPINFOHEADER pInfoHeader;
|
||||
|
||||
memset(&pHeader, 0, sizeof(BITMAPFILEHEADER));
|
||||
memset(&pInfoHeader, 0, sizeof(BITMAPINFOHEADER));
|
||||
|
||||
pHeader.bfType = 0x4D42;
|
||||
pHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + m_iWidth * m_iHeight * 3;
|
||||
pHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
|
||||
|
||||
pInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
pInfoHeader.biWidth = m_iWidth;
|
||||
pInfoHeader.biHeight = m_iHeight;
|
||||
pInfoHeader.biPlanes = 1;
|
||||
pInfoHeader.biBitCount = 24;
|
||||
pInfoHeader.biCompression = 0;
|
||||
pInfoHeader.biSizeImage = m_iWidth * m_iHeight * 3;
|
||||
|
||||
outputFile.Write(sizeof(BITMAPFILEHEADER), &pHeader);
|
||||
outputFile.Write(sizeof(BITMAPINFOHEADER), &pInfoHeader);
|
||||
|
||||
unsigned char cRGB[3];
|
||||
|
||||
for (int i = m_iHeight - 1; i >= 0; i--)
|
||||
{
|
||||
for (int j = 0; j < m_iWidth; j++)
|
||||
{
|
||||
cRGB[0] = m_pBuffer[(i * m_iWidth) + j];
|
||||
cRGB[1] = *cRGB;
|
||||
|
||||
cRGB[2] = *cRGB;
|
||||
|
||||
outputFile.Write(3, cRGB);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
Vec2 CFontTexture::GetKerning(uint32_t leftGlyph, uint32_t rightGlyph)
|
||||
{
|
||||
return m_pGlyphCache.GetKerning(leftGlyph, rightGlyph);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
float CFontTexture::GetAscenderToHeightRatio()
|
||||
{
|
||||
return m_pGlyphCache.GetAscenderToHeightRatio();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontTexture::CreateSlotList(int iListSize)
|
||||
{
|
||||
int y, x;
|
||||
|
||||
for (int i = 0; i < iListSize; i++)
|
||||
{
|
||||
CTextureSlot* pTextureSlot = new CTextureSlot;
|
||||
|
||||
if (!pTextureSlot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
pTextureSlot->iTextureSlot = i;
|
||||
pTextureSlot->Reset();
|
||||
|
||||
y = i / m_iWidthCellCount;
|
||||
x = i % m_iWidthCellCount;
|
||||
|
||||
pTextureSlot->vTexCoord[0] = (float)(x * m_fTextureCellWidth) + (0.5f / (float)m_iWidth);
|
||||
pTextureSlot->vTexCoord[1] = (float)(y * m_fTextureCellHeight) + (0.5f / (float)m_iHeight);
|
||||
|
||||
m_pSlotList.push_back(pTextureSlot);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontTexture::ReleaseSlotList()
|
||||
{
|
||||
CTextureSlotListItor pItor = m_pSlotList.begin();
|
||||
|
||||
while (pItor != m_pSlotList.end())
|
||||
{
|
||||
delete (*pItor);
|
||||
|
||||
pItor = m_pSlotList.erase(pItor);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CFontTexture::UpdateSlot(int iSlot, uint16 wSlotUsage, uint32 cChar, float sizeRatio, const Vec2i& glyphSize, const CFFont::FontHintParams& fontHintParams)
|
||||
{
|
||||
CTextureSlot* pSlot = m_pSlotList[iSlot];
|
||||
|
||||
if (!pSlot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
CTextureSlotTableItor pItor = m_pSlotTable.find(GetTextureSlotKey(pSlot->cCurrentChar, pSlot->glyphSize));
|
||||
|
||||
if (pItor != m_pSlotTable.end())
|
||||
{
|
||||
m_pSlotTable.erase(pItor);
|
||||
}
|
||||
m_pSlotTable.insert(AZStd::pair<CryFont::FontTexture::CTextureSlotKey, CTextureSlot*>(GetTextureSlotKey(cChar, glyphSize), pSlot));
|
||||
pSlot->glyphSize = glyphSize;
|
||||
pSlot->wSlotUsage = wSlotUsage;
|
||||
pSlot->cCurrentChar = cChar;
|
||||
|
||||
int iWidth = 0;
|
||||
int iHeight = 0;
|
||||
|
||||
// blit the char glyph into the texture
|
||||
int x = pSlot->iTextureSlot % m_iWidthCellCount;
|
||||
int y = pSlot->iTextureSlot / m_iWidthCellCount;
|
||||
|
||||
CGlyphBitmap* pGlyphBitmap;
|
||||
|
||||
if (glyphSize.x > 0 && glyphSize.y > 0)
|
||||
{
|
||||
m_pGlyphCache.SetGlyphBitmapSize(glyphSize.x, glyphSize.y, sizeRatio);
|
||||
}
|
||||
|
||||
if (!m_pGlyphCache.GetGlyph(&pGlyphBitmap, &pSlot->iHoriAdvance, &iWidth, &iHeight, pSlot->iCharOffsetX, pSlot->iCharOffsetY, cChar, glyphSize, fontHintParams))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
pSlot->iCharWidth = iWidth;
|
||||
pSlot->iCharHeight = iHeight;
|
||||
|
||||
// Add a pixel along width and height to avoid artifacts being rendered
|
||||
// from a previous glyph in this slot due to bilinear filtering. The source
|
||||
// glyph bitmap buffer is presumed to be cleared prior to FreeType rendering
|
||||
// to the bitmap.
|
||||
const int blitWidth = AZ::GetMin<int>(iWidth + 1, m_iCellWidth);
|
||||
const int blitHeight = AZ::GetMin<int>(iHeight + 1, m_iCellHeight);
|
||||
|
||||
pGlyphBitmap->BlitTo8(m_pBuffer, 0, 0,
|
||||
blitWidth, blitHeight, x * m_iCellWidth, y * m_iCellHeight, m_iWidth);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
void CFontTexture::CreateGradientSlot()
|
||||
{
|
||||
CTextureSlot* pSlot = GetGradientSlot();
|
||||
assert(pSlot->cCurrentChar == (uint32)~0); // 0 needs to be unused spot
|
||||
|
||||
pSlot->Reset();
|
||||
pSlot->iCharWidth = m_iCellWidth - 2;
|
||||
pSlot->iCharHeight = m_iCellHeight - 2;
|
||||
pSlot->SetNotReusable();
|
||||
|
||||
int x = pSlot->iTextureSlot % m_iWidthCellCount;
|
||||
int y = pSlot->iTextureSlot / m_iWidthCellCount;
|
||||
|
||||
assert(sizeof(*m_pBuffer) == sizeof(uint8));
|
||||
uint8* pBuffer = &m_pBuffer[x * m_iCellWidth + y * m_iCellHeight * m_iWidth];
|
||||
|
||||
for (uint32 dwY = 0; dwY < pSlot->iCharHeight; ++dwY)
|
||||
{
|
||||
for (uint32 dwX = 0; dwX < pSlot->iCharWidth; ++dwX)
|
||||
{
|
||||
pBuffer[dwX + dwY * m_iWidth] = dwY * 255 / (pSlot->iCharHeight - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CTextureSlot* CFontTexture::GetGradientSlot()
|
||||
{
|
||||
return m_pSlotList[0];
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CryFont::FontTexture::CTextureSlotKey CFontTexture::GetTextureSlotKey(uint32 cChar, const Vec2i& glyphSize) const
|
||||
{
|
||||
const Vec2i clampedGlyphSize(ClampGlyphSize(glyphSize, m_iCellWidth, m_iCellHeight));
|
||||
return CryFont::FontTexture::CTextureSlotKey(clampedGlyphSize, cChar);
|
||||
}
|
||||
|
||||
Vec2i CFontTexture::ClampGlyphSize(const Vec2i& glyphSize, int cellWidth, int cellHeight)
|
||||
{
|
||||
const Vec2i maxCellDimensions(cellWidth, cellHeight);
|
||||
Vec2i clampedGlyphSize(glyphSize);
|
||||
|
||||
const bool hasZeroDimension = glyphSize.x == 0 || glyphSize.y == 0;
|
||||
const bool isDefaultSize = glyphSize == CCryFont::defaultGlyphSize;
|
||||
const bool exceedsDimensions = glyphSize.x > cellWidth || glyphSize.y > cellHeight;
|
||||
const bool useMaxCellDimension = hasZeroDimension || isDefaultSize || exceedsDimensions;
|
||||
if (useMaxCellDimension)
|
||||
{
|
||||
clampedGlyphSize = maxCellDimensions;
|
||||
}
|
||||
|
||||
return clampedGlyphSize;
|
||||
}
|
||||
|
||||
#endif // #if !defined(USE_NULLFONT_ALWAYS)
|
||||
@@ -1,301 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_CRYFONT_FONTTEXTURE_H
|
||||
#define CRYINCLUDE_CRYFONT_FONTTEXTURE_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#include "GlyphCache.h"
|
||||
#include "GlyphBitmap.h"
|
||||
#include "CryFont.h"
|
||||
#include "FFont.h"
|
||||
|
||||
typedef uint8 FONT_TEXTURE_TYPE;
|
||||
|
||||
// the number of slots in the glyph cache
|
||||
// each slot ocupies ((glyph_bitmap_width * glyph_bitmap_height) + 24) bytes
|
||||
#define FONT_GLYPH_CACHE_SIZE (1)
|
||||
|
||||
// the glyph spacing in font texels between characters in proportional font mode (more correct would be to take the value in the character)
|
||||
#define FONT_GLYPH_PROP_SPACING (1)
|
||||
|
||||
// the size of a rendered space, this value gets multiplied by the default characted width
|
||||
#define FONT_SPACE_SIZE (0.5f)
|
||||
|
||||
// don't draw this char (used to avoid drawing color codes)
|
||||
#define FONT_NOT_DRAWABLE_CHAR (0xffff)
|
||||
|
||||
// smoothing methods
|
||||
#define FONT_SMOOTH_NONE 0
|
||||
#define FONT_SMOOTH_BLUR 1
|
||||
#define FONT_SMOOTH_SUPERSAMPLE 2
|
||||
|
||||
// smoothing amounts
|
||||
#define FONT_SMOOTH_AMOUNT_NONE 0
|
||||
#define FONT_SMOOTH_AMOUNT_2X 1
|
||||
#define FONT_SMOOTH_AMOUNT_4X 2
|
||||
|
||||
//! Stores glyph meta-data read from the font (FreeType).
|
||||
//!
|
||||
//! \sa CCacheSlot
|
||||
typedef struct CTextureSlot
|
||||
{
|
||||
Vec2i glyphSize = CCryFont::defaultGlyphSize; //!< Size of the rendered glyph stored in the font texture
|
||||
uint16 wSlotUsage; //!< For LRU strategy, 0xffff is never released
|
||||
uint32 cCurrentChar; //!< ~0 if not used for characters
|
||||
int iTextureSlot;
|
||||
int iHoriAdvance; //!< Advance width. See FT_Glyph_Metrics::horiAdvance.
|
||||
float vTexCoord[2]; //!< Character position in the texture (not yet half texel corrected)
|
||||
uint8 iCharWidth; //!< Glyph width (in pixel)
|
||||
uint8 iCharHeight; //!< Glyph height (in pixel)
|
||||
AZ::s32 iCharOffsetX; //!< Glyph's left-side bearing (in pixels). See FT_GlyphSlotRec::bitmap_left.
|
||||
AZ::s32 iCharOffsetY; //!< Glyph's top bearing (in pixels). See FT_GlyphSlotRec::bitmap_top.
|
||||
|
||||
void Reset()
|
||||
{
|
||||
wSlotUsage = 0;
|
||||
cCurrentChar = ~0;
|
||||
iHoriAdvance = 0;
|
||||
iCharWidth = 0;
|
||||
iCharHeight = 0;
|
||||
iCharOffsetX = 0;
|
||||
iCharOffsetY = 0;
|
||||
}
|
||||
|
||||
void SetNotReusable()
|
||||
{
|
||||
wSlotUsage = 0xffff;
|
||||
}
|
||||
|
||||
void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const {}
|
||||
} CTextureSlot;
|
||||
|
||||
|
||||
typedef std::vector<CTextureSlot*> CTextureSlotList;
|
||||
typedef std::vector<CTextureSlot*>::iterator CTextureSlotListItor;
|
||||
|
||||
namespace CryFont
|
||||
{
|
||||
namespace FontTexture
|
||||
{
|
||||
//! Height and width pair for glyph size mapping
|
||||
typedef Vec2i CGlyphSizeType;
|
||||
|
||||
//! Pair for mapping a height and width size to a UTF32 character/glyph
|
||||
typedef AZStd::pair<CGlyphSizeType, uint32> CTextureSlotKey;
|
||||
|
||||
//! Hasher for texture slot table keys (glyphsize-char code pair)
|
||||
//!
|
||||
//! Instead of creating our own custom hash, the types are broken down to their
|
||||
//! native types (ints) and passed to existing hashes that handle those types.
|
||||
struct HashTextureSlotTableKey
|
||||
{
|
||||
typedef CTextureSlotKey ArgumentType;
|
||||
typedef AZStd::size_t ResultType;
|
||||
typedef AZStd::pair<int32, int32> Int32Pair;
|
||||
typedef AZStd::pair<Int32Pair, uint32> Int32PairU32Pair;
|
||||
ResultType operator()(const ArgumentType& value) const
|
||||
{
|
||||
// Utiliize existing hash function for pairs of ints
|
||||
AZStd::hash<Int32PairU32Pair> pairHash;
|
||||
return pairHash(Int32PairU32Pair(Int32Pair(value.first.x, value.first.y), value.second));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//! Maps size-speicifc UTF32 glyphs to their corresponding texture slots
|
||||
typedef AZStd::unordered_map<CryFont::FontTexture::CTextureSlotKey, CTextureSlot*, CryFont::FontTexture::HashTextureSlotTableKey> CTextureSlotTable;
|
||||
|
||||
typedef CTextureSlotTable::iterator CTextureSlotTableItor;
|
||||
typedef CTextureSlotTable::const_iterator CTextureSlotTableItorConst;
|
||||
|
||||
#ifdef WIN64
|
||||
#undef GetCharWidth
|
||||
#undef GetCharHeight
|
||||
#endif
|
||||
|
||||
//! Stores the glyphs of a font within a single texture.
|
||||
//!
|
||||
//! The texture resolution is configurable, as is the number of slots within
|
||||
//! the texture.
|
||||
//!
|
||||
//! A texture slot contains a single glyph within the font and are uniform
|
||||
//! size throughout the font texture (each slot occupies the same size
|
||||
//! regardless of the size of a glyph being stored, so a '.' occupies the
|
||||
//! same amount of space as a 'W', for example).
|
||||
//!
|
||||
//! Font glyph buffers are read from FreeType and copied into the texture.
|
||||
//!
|
||||
//! \sa CTextureSlot, CFontRenderer
|
||||
class CFontTexture
|
||||
{
|
||||
public:
|
||||
CFontTexture();
|
||||
~CFontTexture();
|
||||
|
||||
int CreateFromFile(const string& szFileName, int iWidth, int iHeight, int iSmoothMethod, int iSmoothAmount, int iWidthCharCount = 16, int iHeightCharCount = 16);
|
||||
|
||||
//! Default texture slot width/height is 16x8 slots, allowing for 128 glyphs to be stored in the font texture. This was
|
||||
//! previously 16x16, allowing 256 glyphs to be stored. For reference, there are 95 printable ASCII characters, so by
|
||||
//! reducing the number of slots, the height of the font texture can be halved (for some nice memory savings). We may
|
||||
//! want to make this configurable in the font XML (especially for languages with a large number of printable chars).
|
||||
int CreateFromMemory(unsigned char* pFileData, int iDataSize, int iWidth, int iHeight, int iSmoothMethod, int iSmoothAmount, int iWidthCharCount, int iHeightCharCount, float sizeRatio);
|
||||
|
||||
int Create(int iWidth, int iHeight, int iSmoothMethod, int iSmoothAmount, int iWidthCharCount = 16, int iHeightCharCount = 16, float sizeRatio = IFFontConstants::defaultSizeRatio);
|
||||
int Release();
|
||||
|
||||
int SetEncoding(FT_Encoding pEncoding) { return m_pGlyphCache.SetEncoding(pEncoding); }
|
||||
FT_Encoding GetEncoding() { return m_pGlyphCache.GetEncoding(); }
|
||||
|
||||
int GetCellWidth() { return m_iCellWidth; }
|
||||
int GetCellHeight() { return m_iCellHeight; }
|
||||
|
||||
int GetWidth() { return m_iWidth; }
|
||||
int GetHeight() { return m_iHeight; }
|
||||
|
||||
int GetWidthCellCount() { return m_iWidthCellCount; }
|
||||
int GetHeightCellCount() { return m_iHeightCellCount; }
|
||||
|
||||
float GetTextureCellWidth() { return m_fTextureCellWidth; }
|
||||
float GetTextureCellHeight() { return m_fTextureCellHeight; }
|
||||
|
||||
FONT_TEXTURE_TYPE* GetBuffer() { return m_pBuffer; }
|
||||
|
||||
uint32 GetSlotChar(int iSlot) const;
|
||||
CTextureSlot* GetCharSlot(uint32 cChar, const Vec2i& glyphSize = CCryFont::defaultGlyphSize);
|
||||
CTextureSlot* GetGradientSlot();
|
||||
|
||||
CTextureSlot* GetLRUSlot();
|
||||
CTextureSlot* GetMRUSlot();
|
||||
|
||||
//! Returns 1 if texture updated, returns 2 if texture not updated, returns 0 on error
|
||||
//! \param szString A string of glyphs (UTF8) to added to the font texture (if they don't already exist in the font texture)
|
||||
//! \param pUpdated is the number of slots updated
|
||||
//! \param sizeRatio A sizing scale that gets applied to all glyphs sizes before they are stored in the font texture.
|
||||
//! \param glyphSize The resolution to render the glyphs in szString at.
|
||||
//! \param glyphFlags Controls hinting behavior for glyphs rendered to the font texture.
|
||||
int PreCacheString(const char* szString, int* pUpdated = 0, float sizeRatio = IFFontConstants::defaultSizeRatio, const Vec2i& glyphSize = CCryFont::defaultGlyphSize, const CFFont::FontHintParams& glyphFlags = CFFont::FontHintParams());
|
||||
// Arguments:
|
||||
// pSlot - function does nothing if this pointer is 0
|
||||
void GetTextureCoord(CTextureSlot * pSlot, float texCoords[4], int& iCharSizeX, int& iCharSizeY, int& iCharOffsetX, int& iCharOffsetY, const Vec2i& glyphSize = CCryFont::defaultGlyphSize) const;
|
||||
int GetCharacterWidth(uint32 cChar) const;
|
||||
//! Gets the horizontal advance for the given glyph/char.
|
||||
//! \param cChar The glyph (UTF32) to get the horizontal advance for.
|
||||
//! \param glyphSize The rendered size of the glyph to get the advance for (the same glyph could be stored in the font texture at multiple sizes).
|
||||
int GetHorizontalAdvance(uint32 cChar, const Vec2i& glyphSize = CCryFont::defaultGlyphSize) const;
|
||||
// int GetCharHeightByChar(wchar_t cChar);
|
||||
|
||||
// useful for special feature rendering interleaved with fonts (e.g. box behind the text)
|
||||
void CreateGradientSlot();
|
||||
|
||||
int WriteToFile(const string& szFileName);
|
||||
|
||||
void GetMemoryUsage(ICrySizer* pSizer) const
|
||||
{
|
||||
pSizer->AddObject(this, sizeof(*this));
|
||||
pSizer->AddObject(m_pGlyphCache);
|
||||
pSizer->AddObject(m_pSlotList);
|
||||
//pSizer->AddContainer(m_pSlotTable);
|
||||
pSizer->AddObject(m_pBuffer, m_iWidth * m_iHeight * sizeof(FONT_TEXTURE_TYPE));
|
||||
}
|
||||
|
||||
bool GetMonospaced() const { return m_pGlyphCache.GetMonospaced(); }
|
||||
|
||||
Vec2 GetKerning(uint32_t leftGlyph, uint32_t rightGlyph);
|
||||
|
||||
float GetAscenderToHeightRatio();
|
||||
|
||||
public: // ---------------------------------------------------------------
|
||||
|
||||
//! Clamps the given glyph size to the given max cell width and height dimensions.
|
||||
static Vec2i ClampGlyphSize(const Vec2i& glyphSize, int cellWidth, int cellHeight);
|
||||
|
||||
private: // ---------------------------------------------------------------
|
||||
|
||||
int CreateSlotList(int iListSize);
|
||||
int ReleaseSlotList();
|
||||
|
||||
//! Updates the given font texture slot with the given glyph (UTF8) with the given parameters. If the glyph doesn't
|
||||
//! exist in the font texture at the given size, then the glyph will be rendered to the font texture with the given
|
||||
//! parameters.
|
||||
//! \param iSlot Index of the texture slot to update within the slot list.
|
||||
//! \param wSlotUsage Used for LRU strategy to determine how many times a glyph is referenced for retention within the font texture (before eviction).
|
||||
//! \param cChar UTF32 glyph to store within the slot.
|
||||
//! \param sizeRatio A sizing scale that should be applied to the glyph before being stored within the font texture.
|
||||
//! \param glyphSize The size of the glyph to be rendered at within the font texture.
|
||||
//! \param glyphFlags Specifies hinting behavior that should be applied to the glyph when rendered to the font texture.
|
||||
int UpdateSlot(int iSlot, uint16 wSlotUsage, uint32 cChar, float sizeRatio, const Vec2i& glyphSize = CCryFont::defaultGlyphSize, const CFFont::FontHintParams& glyphFlags = CFFont::FontHintParams());
|
||||
|
||||
CryFont::FontTexture::CTextureSlotKey GetTextureSlotKey(uint32 cChar, const Vec2i& glyphSize = CCryFont::defaultGlyphSize) const;
|
||||
|
||||
//! Calculates scaling info that should be applied when the rendered glyph size doesn't match the maximum glyph slot resolution.
|
||||
//!
|
||||
//! Glyphs can be re-rendered to glyph slots at smaller resolutions for pixel-perfect resolution (rather than applying a scale
|
||||
//! to glyphs rendered at larger sizes). These scaling values allow clients of the font texture to use the glyphs without regard
|
||||
//! to whether the glyphs have been re-rendered or not.
|
||||
float GetRequestSizeWidthScale(const Vec2i& glyphSize) const
|
||||
{
|
||||
const int cellWidth = m_iCellWidth == 0 ? 1 : m_iCellWidth;
|
||||
const float invCellWidth = 1.0f / cellWidth;
|
||||
return glyphSize.x > 0 ? glyphSize.x * invCellWidth : 1.0f;
|
||||
}
|
||||
|
||||
//! Calculates scaling info that should be applied when the rendered glyph size doesn't match the maximum glyph slot resolution.
|
||||
//!
|
||||
//! Glyphs can be re-rendered to glyph slots at smaller resolutions for pixel-perfect resolution (rather than applying a scale
|
||||
//! to glyphs rendered at larger sizes). These scaling values allow clients of the font texture to use the glyphs without regard
|
||||
//! to whether the glyphs have been re-rendered or not.
|
||||
float GetRequestSizeHeightScale(const Vec2i& glyphSize) const
|
||||
{
|
||||
const int cellHeight = m_iCellHeight == 0 ? 1 : m_iCellHeight;
|
||||
const float invCellHeight = 1.0f / cellHeight;
|
||||
return glyphSize.y > 0 ? glyphSize.y * invCellHeight : 1.0f;
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
|
||||
int m_iWidth; // whole texture cache width
|
||||
int m_iHeight; // whole texture cache height
|
||||
|
||||
float m_fInvWidth;
|
||||
float m_fInvHeight;
|
||||
|
||||
int m_iCellWidth;
|
||||
int m_iCellHeight;
|
||||
|
||||
float m_fTextureCellWidth;
|
||||
float m_fTextureCellHeight;
|
||||
|
||||
int m_iWidthCellCount;
|
||||
int m_iHeightCellCount;
|
||||
|
||||
int m_nTextureSlotCount;
|
||||
|
||||
int m_iSmoothMethod;
|
||||
int m_iSmoothAmount;
|
||||
|
||||
CGlyphCache m_pGlyphCache;
|
||||
CTextureSlotList m_pSlotList;
|
||||
CTextureSlotTable m_pSlotTable;
|
||||
|
||||
FONT_TEXTURE_TYPE* m_pBuffer; // [y*iWidth * x] x=0..iWidth-1, y=0..iHeight-1
|
||||
|
||||
uint16 m_wSlotUsage;
|
||||
};
|
||||
|
||||
#endif // #if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#endif // CRYINCLUDE_CRYFONT_FONTTEXTURE_H
|
||||
@@ -1,396 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Purpose:
|
||||
// - Hold a glyph bitmap and blit it to the main texture
|
||||
|
||||
#include "CryFont_precompiled.h"
|
||||
#include "GlyphBitmap.h"
|
||||
#include <math.h>
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CGlyphBitmap::CGlyphBitmap()
|
||||
: m_iWidth(0)
|
||||
, m_iHeight(0)
|
||||
, m_pBuffer(0)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CGlyphBitmap::~CGlyphBitmap()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphBitmap::Create(int iWidth, int iHeight)
|
||||
{
|
||||
Release();
|
||||
|
||||
m_pBuffer = new unsigned char[iWidth * iHeight];
|
||||
|
||||
if (!m_pBuffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_iWidth = iWidth;
|
||||
m_iHeight = iHeight;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphBitmap::Release()
|
||||
{
|
||||
if (m_pBuffer)
|
||||
{
|
||||
delete[] m_pBuffer;
|
||||
}
|
||||
m_pBuffer = 0;
|
||||
m_iWidth = m_iHeight = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphBitmap::Blur(int iIterations)
|
||||
{
|
||||
int cSum;
|
||||
int yOffset;
|
||||
int yupOffset;
|
||||
int ydownOffset;
|
||||
|
||||
for (int i = 0; i < iIterations; i++)
|
||||
{
|
||||
for (int y = 0; y < m_iHeight; y++)
|
||||
{
|
||||
yOffset = y * m_iWidth;
|
||||
|
||||
if (y - 1 >= 0)
|
||||
{
|
||||
yupOffset = (y - 1) * m_iWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
yupOffset = (y) * m_iWidth;
|
||||
}
|
||||
|
||||
if (y + 1 < m_iHeight)
|
||||
{
|
||||
ydownOffset = (y + 1) * m_iWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
ydownOffset = (y) * m_iWidth;
|
||||
}
|
||||
|
||||
for (int x = 0; x < m_iWidth; x++)
|
||||
{
|
||||
cSum = m_pBuffer[yupOffset + x] + m_pBuffer[ydownOffset + x];
|
||||
|
||||
if (x - 1 >= 0)
|
||||
{
|
||||
cSum += m_pBuffer[yOffset + x - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
cSum += m_pBuffer[yOffset + x];
|
||||
}
|
||||
|
||||
if (x + 1 < m_iWidth)
|
||||
{
|
||||
cSum += m_pBuffer[yOffset + x + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
cSum += m_pBuffer[yOffset + x];
|
||||
}
|
||||
|
||||
m_pBuffer[yOffset + x] = cSum >> 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphBitmap::Scale(float fScaleX, float fScaleY)
|
||||
{
|
||||
int iNewWidth = (int)(m_iWidth * fScaleX);
|
||||
int iNewHeight = (int)(m_iHeight * fScaleY);
|
||||
|
||||
unsigned char* pNewBuffer = new unsigned char[iNewWidth * iNewHeight];
|
||||
|
||||
if (!pNewBuffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float xFactor = m_iWidth / (float)iNewWidth;
|
||||
float yFactor = m_iHeight / (float)iNewHeight;
|
||||
|
||||
float xFractioned, yFractioned, xFraction, yFraction, oneMinusX, oneMinusY, fR0, fR1;
|
||||
int xCeil, yCeil, xFloor, yFloor, yNewOffset;
|
||||
|
||||
unsigned char c0, c1, c2, c3;
|
||||
|
||||
for (int y = 0; y < iNewHeight; ++y)
|
||||
{
|
||||
yFractioned = y * yFactor;
|
||||
yFloor = (int)floor_tpl(yFractioned);
|
||||
yCeil = yFloor + 1;
|
||||
|
||||
if (yCeil >= m_iHeight)
|
||||
{
|
||||
yCeil = yFloor;
|
||||
}
|
||||
|
||||
yFraction = yFractioned - yFloor;
|
||||
oneMinusY = 1.0f - yFraction;
|
||||
|
||||
yNewOffset = y * iNewWidth;
|
||||
|
||||
for (int x = 0; x < iNewWidth; ++x)
|
||||
{
|
||||
xFractioned = x * xFactor;
|
||||
xFloor = (int)floor_tpl(xFractioned);
|
||||
xCeil = xFloor + 1;
|
||||
|
||||
if (xCeil >= m_iWidth)
|
||||
{
|
||||
xCeil = xFloor;
|
||||
}
|
||||
|
||||
xFraction = xFractioned - xFloor;
|
||||
oneMinusX = 1.0f - xFraction;
|
||||
|
||||
c0 = m_pBuffer[yFloor * m_iWidth + xFloor];
|
||||
c1 = m_pBuffer[yFloor * m_iWidth + xCeil];
|
||||
c2 = m_pBuffer[yCeil * m_iWidth + xFloor];
|
||||
c3 = m_pBuffer[yCeil * m_iWidth + xCeil];
|
||||
|
||||
fR0 = (oneMinusX * c0 + xFraction * c1);
|
||||
fR1 = (oneMinusX * c2 + xFraction * c3);
|
||||
|
||||
pNewBuffer[yNewOffset + x] = (unsigned char)((oneMinusY * fR0) + (yFraction * fR1));
|
||||
}
|
||||
}
|
||||
|
||||
m_iWidth = iNewWidth;
|
||||
m_iHeight = iNewHeight;
|
||||
|
||||
delete[] m_pBuffer;
|
||||
m_pBuffer = pNewBuffer;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphBitmap::Clear()
|
||||
{
|
||||
memset(m_pBuffer, 0, m_iWidth * m_iHeight);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphBitmap::BlitTo8(unsigned char* pBuffer, int iSrcX, int iSrcY, int iSrcWidth, int iSrcHeight, int iDestX, int iDestY, int iDestWidth)
|
||||
{
|
||||
int ySrcOffset, yDestOffset;
|
||||
|
||||
for (int y = 0; y < iSrcHeight; y++)
|
||||
{
|
||||
ySrcOffset = (iSrcY + y) * m_iWidth;
|
||||
yDestOffset = (iDestY + y) * iDestWidth;
|
||||
|
||||
for (int x = 0; x < iSrcWidth; x++)
|
||||
{
|
||||
pBuffer[yDestOffset + iDestX + x] = m_pBuffer[ySrcOffset + iSrcX + x];
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphBitmap::BlitTo32(unsigned int* pBuffer, int iSrcX, int iSrcY, int iSrcWidth, int iSrcHeight, int iDestX, int iDestY, int iDestWidth)
|
||||
{
|
||||
int ySrcOffset, yDestOffset;
|
||||
char cColor;
|
||||
|
||||
for (int y = 0; y < iSrcHeight; y++)
|
||||
{
|
||||
ySrcOffset = (iSrcY + y) * m_iWidth;
|
||||
yDestOffset = (iDestY + y) * iDestWidth;
|
||||
|
||||
for (int x = 0; x < iSrcWidth; x++)
|
||||
{
|
||||
cColor = m_pBuffer[ySrcOffset + iSrcX + x];
|
||||
|
||||
pBuffer[yDestOffset + iDestX + x] = (cColor << 24) | (255 << 16) | (255 << 8) | 255;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphBitmap::BlitScaledTo8(unsigned char* pBuffer, [[maybe_unused]] int iSrcX, int iSrcY, int iSrcWidth, int iSrcHeight, int iDestX, [[maybe_unused]] int iDestY, int iDestWidth, int iDestHeight, int iDestBufferWidth)
|
||||
{
|
||||
int iNewWidth = (int)iDestWidth;
|
||||
int iNewHeight = (int)iDestHeight;
|
||||
|
||||
unsigned char* pNewBuffer = pBuffer;
|
||||
|
||||
float xFactor = iSrcWidth / (float)iNewWidth;
|
||||
float yFactor = iSrcHeight / (float)iNewHeight;
|
||||
|
||||
float xFractioned, yFractioned, xFraction, yFraction, oneMinusX, oneMinusY, fR0, fR1;
|
||||
int xCeil, yCeil, xFloor, yFloor, yNewOffset;
|
||||
|
||||
unsigned char c0, c1, c2, c3;
|
||||
|
||||
for (int y = 0; y < iNewHeight; ++y)
|
||||
{
|
||||
yFractioned = y * yFactor;
|
||||
yFloor = (int)floor_tpl(yFractioned);
|
||||
yCeil = yFloor + 1;
|
||||
|
||||
yFraction = yFractioned - yFloor;
|
||||
oneMinusY = 1.0f - yFraction;
|
||||
|
||||
yNewOffset = y * iDestBufferWidth;
|
||||
|
||||
yFloor += iSrcY;
|
||||
yCeil += iSrcY;
|
||||
|
||||
if (yCeil >= m_iHeight)
|
||||
{
|
||||
yCeil = yFloor;
|
||||
}
|
||||
|
||||
for (int x = 0; x < iNewWidth; ++x)
|
||||
{
|
||||
xFractioned = x * xFactor;
|
||||
xFloor = (int)floor_tpl(xFractioned);
|
||||
xCeil = xFloor + 1;
|
||||
|
||||
xFraction = xFractioned - xFloor;
|
||||
oneMinusX = 1.0f - xFraction;
|
||||
|
||||
xFloor += iSrcY;
|
||||
xCeil += iSrcY;
|
||||
|
||||
if (xCeil >= m_iWidth)
|
||||
{
|
||||
xCeil = xFloor;
|
||||
}
|
||||
|
||||
c0 = m_pBuffer[yFloor * m_iWidth + xFloor];
|
||||
c1 = m_pBuffer[yFloor * m_iWidth + xCeil];
|
||||
c2 = m_pBuffer[yCeil * m_iWidth + xFloor];
|
||||
c3 = m_pBuffer[yCeil * m_iWidth + xCeil];
|
||||
|
||||
fR0 = (oneMinusX * c0 + xFraction * c1);
|
||||
fR1 = (oneMinusX * c2 + xFraction * c3);
|
||||
|
||||
pNewBuffer[yNewOffset + x + iDestX] = (unsigned char)((oneMinusY * fR0) + (yFraction * fR1));
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#if __GNUC__ >= 4 && __GNUC__MINOR__ < 7
|
||||
#pragma GCC diagnostic ignored "-Woverflow"
|
||||
#endif
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphBitmap::BlitScaledTo32(unsigned char* pBuffer, [[maybe_unused]] int iSrcX, int iSrcY, int iSrcWidth, int iSrcHeight, int iDestX, [[maybe_unused]] int iDestY, int iDestWidth, int iDestHeight, int iDestBufferWidth)
|
||||
{
|
||||
int iNewWidth = (int)iDestWidth;
|
||||
int iNewHeight = (int)iDestHeight;
|
||||
|
||||
unsigned char* pNewBuffer = pBuffer;
|
||||
|
||||
float xFactor = iSrcWidth / (float)iNewWidth;
|
||||
float yFactor = iSrcHeight / (float)iNewHeight;
|
||||
|
||||
float xFractioned, yFractioned, xFraction, yFraction, oneMinusX, oneMinusY, fR0, fR1;
|
||||
int xCeil, yCeil, xFloor, yFloor, yNewOffset;
|
||||
|
||||
unsigned char c0, c1, c2, c3, cColor;
|
||||
|
||||
for (int y = 0; y < iNewHeight; ++y)
|
||||
{
|
||||
yFractioned = y * yFactor;
|
||||
yFloor = (int)floor_tpl(yFractioned);
|
||||
yCeil = yFloor + 1;
|
||||
|
||||
yFraction = yFractioned - yFloor;
|
||||
oneMinusY = 1.0f - yFraction;
|
||||
|
||||
yNewOffset = y * iDestBufferWidth;
|
||||
|
||||
yFloor += iSrcY;
|
||||
yCeil += iSrcY;
|
||||
|
||||
if (yCeil >= m_iHeight)
|
||||
{
|
||||
yCeil = yFloor;
|
||||
}
|
||||
|
||||
for (int x = 0; x < iNewWidth; ++x)
|
||||
{
|
||||
xFractioned = x * xFactor;
|
||||
xFloor = (int)floor_tpl(xFractioned);
|
||||
xCeil = xFloor + 1;
|
||||
|
||||
xFraction = xFractioned - xFloor;
|
||||
oneMinusX = 1.0f - xFraction;
|
||||
|
||||
xFloor += iSrcY;
|
||||
xCeil += iSrcY;
|
||||
|
||||
if (xCeil >= m_iWidth)
|
||||
{
|
||||
xCeil = xFloor;
|
||||
}
|
||||
|
||||
c0 = m_pBuffer[yFloor * m_iWidth + xFloor];
|
||||
c1 = m_pBuffer[yFloor * m_iWidth + xCeil];
|
||||
c2 = m_pBuffer[yCeil * m_iWidth + xFloor];
|
||||
c3 = m_pBuffer[yCeil * m_iWidth + xCeil];
|
||||
|
||||
fR0 = (oneMinusX * c0 + xFraction * c1);
|
||||
fR1 = (oneMinusX * c2 + xFraction * c3);
|
||||
|
||||
cColor = (unsigned char)((oneMinusY * fR0) + (yFraction * fR1));
|
||||
|
||||
pNewBuffer[yNewOffset + x + iDestX] = 0xffffff | (cColor << 24);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
#if defined(__GNUC__)
|
||||
#if __GNUC__ >= 4 && __GNUC__MINOR__ < 7
|
||||
#pragma GCC diagnostic error "-Woverflow"
|
||||
#endif
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Purpose : Hold a glyph bitmap and blit it to the main texture
|
||||
|
||||
#ifndef CRYINCLUDE_CRYFONT_GLYPHBITMAP_H
|
||||
#define CRYINCLUDE_CRYFONT_GLYPHBITMAP_H
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
class CGlyphBitmap
|
||||
{
|
||||
public:
|
||||
CGlyphBitmap();
|
||||
~CGlyphBitmap();
|
||||
|
||||
int Create(int iWidth, int iHeight);
|
||||
int Release();
|
||||
|
||||
unsigned char* GetBuffer() { return m_pBuffer; };
|
||||
|
||||
int Blur(int iIterations);
|
||||
int Scale(float fScaleX, float fScaleY);
|
||||
|
||||
int Clear();
|
||||
|
||||
int BlitTo8(unsigned char* pBuffer, int iSrcX, int iSrcY, int iSrcWidth, int iSrcHeight, int iDestX, int iDestY, int iDestWidth);
|
||||
int BlitTo32(unsigned int* pBuffer, int iSrcX, int iSrcY, int iSrcWidth, int iSrcHeight, int iDestX, int iDestY, int iDestWidth);
|
||||
|
||||
int BlitScaledTo8(unsigned char* pBuffer, int iSrcX, int iSrcY, int iSrcWidth, int iSrcHeight, int iDestX, int iDestY, int iDestWidth, int iDestHeight, int iDestBufferWidth);
|
||||
int BlitScaledTo32(unsigned char* pBuffer, int iSrcX, int iSrcY, int iSrcWidth, int iSrcHeight, int iDestX, int iDestY, int iDestWidth, int iDestHeight, int iDestBufferWidth);
|
||||
|
||||
int GetWidth() { return m_iWidth; }
|
||||
int GetHeight() { return m_iHeight; }
|
||||
|
||||
void GetMemoryUsage(ICrySizer* pSizer) const
|
||||
{
|
||||
pSizer->AddObject(m_pBuffer, m_iWidth * m_iHeight);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
unsigned char* m_pBuffer;
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_CRYFONT_GLYPHBITMAP_H
|
||||
@@ -1,433 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Purpose:
|
||||
// - Manage and cache glyphs, retrieving them from the renderer as needed
|
||||
|
||||
#include "CryFont_precompiled.h"
|
||||
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#include "GlyphCache.h"
|
||||
#include "FontTexture.h"
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CGlyphCache::CGlyphCache()
|
||||
: m_dwUsage(1)
|
||||
, m_iGlyphBitmapWidth(0)
|
||||
, m_iGlyphBitmapHeight(0)
|
||||
, m_pScaleBitmap(0)
|
||||
{
|
||||
m_pCacheTable.clear();
|
||||
m_pSlotList.clear();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CGlyphCache::~CGlyphCache()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphCache::Create(int iCacheSize, int iGlyphBitmapWidth, int iGlyphBitmapHeight, int iSmoothMethod, int iSmoothAmount, float sizeRatio)
|
||||
{
|
||||
m_iSmoothMethod = iSmoothMethod;
|
||||
m_iSmoothAmount = iSmoothAmount;
|
||||
|
||||
m_iGlyphBitmapWidth = iGlyphBitmapWidth;
|
||||
m_iGlyphBitmapHeight = iGlyphBitmapHeight;
|
||||
|
||||
|
||||
if (!CreateSlotList(iCacheSize))
|
||||
{
|
||||
ReleaseSlotList();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iScaledGlyphWidth = 0;
|
||||
int iScaledGlyphHeight = 0;
|
||||
|
||||
switch (m_iSmoothMethod)
|
||||
{
|
||||
case FONT_SMOOTH_SUPERSAMPLE:
|
||||
{
|
||||
switch (m_iSmoothAmount)
|
||||
{
|
||||
case FONT_SMOOTH_AMOUNT_2X:
|
||||
iScaledGlyphWidth = m_iGlyphBitmapWidth << 1;
|
||||
iScaledGlyphHeight = m_iGlyphBitmapHeight << 1;
|
||||
break;
|
||||
case FONT_SMOOTH_AMOUNT_4X:
|
||||
iScaledGlyphWidth = m_iGlyphBitmapWidth << 2;
|
||||
iScaledGlyphHeight = m_iGlyphBitmapHeight << 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (iScaledGlyphWidth)
|
||||
{
|
||||
m_pScaleBitmap = new CGlyphBitmap;
|
||||
|
||||
if (!m_pScaleBitmap)
|
||||
{
|
||||
Release();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!m_pScaleBitmap->Create(iScaledGlyphWidth, iScaledGlyphHeight))
|
||||
{
|
||||
Release();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_pFontRenderer.SetGlyphBitmapSize(iScaledGlyphWidth, iScaledGlyphHeight, sizeRatio);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pFontRenderer.SetGlyphBitmapSize(m_iGlyphBitmapWidth, m_iGlyphBitmapHeight, sizeRatio);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphCache::Release()
|
||||
{
|
||||
ReleaseSlotList();
|
||||
|
||||
m_pCacheTable.clear();
|
||||
|
||||
if (m_pScaleBitmap)
|
||||
{
|
||||
m_pScaleBitmap->Release();
|
||||
|
||||
delete m_pScaleBitmap;
|
||||
|
||||
m_pScaleBitmap = 0;
|
||||
}
|
||||
|
||||
m_iGlyphBitmapWidth = 0;
|
||||
m_iGlyphBitmapHeight = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphCache::LoadFontFromFile(const string& szFileName)
|
||||
{
|
||||
return m_pFontRenderer.LoadFromFile(szFileName);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphCache::LoadFontFromMemory(unsigned char* pFileBuffer, int iDataSize)
|
||||
{
|
||||
return m_pFontRenderer.LoadFromMemory(pFileBuffer, iDataSize);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphCache::ReleaseFont()
|
||||
{
|
||||
m_pFontRenderer.Release();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphCache::GetGlyphBitmapSize(int* pWidth, int* pHeight)
|
||||
{
|
||||
if (pWidth)
|
||||
{
|
||||
*pWidth = m_iGlyphBitmapWidth;
|
||||
}
|
||||
|
||||
if (pHeight)
|
||||
{
|
||||
*pHeight = m_iGlyphBitmapWidth;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
void CGlyphCache::SetGlyphBitmapSize(int width, int height, float sizeRatio)
|
||||
{
|
||||
m_pFontRenderer.SetGlyphBitmapSize(width, height, sizeRatio);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphCache::PreCacheGlyph(uint32 cChar, const Vec2i& glyphSize, const CFFont::FontHintParams& fontHintParams)
|
||||
{
|
||||
CCacheTable::iterator pItor = m_pCacheTable.find(GetCacheSlotKey(cChar, glyphSize));
|
||||
|
||||
if (pItor != m_pCacheTable.end())
|
||||
{
|
||||
pItor->second->dwUsage = m_dwUsage;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
CCacheSlot* pSlot = GetLRUSlot();
|
||||
|
||||
if (!pSlot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pSlot->dwUsage > 0)
|
||||
{
|
||||
UnCacheGlyph(pSlot->cCurrentChar, pSlot->glyphSize);
|
||||
}
|
||||
|
||||
if (m_pScaleBitmap)
|
||||
{
|
||||
int iOffsetMult = 1;
|
||||
|
||||
switch (m_iSmoothAmount)
|
||||
{
|
||||
case FONT_SMOOTH_AMOUNT_2X:
|
||||
iOffsetMult = 2;
|
||||
break;
|
||||
case FONT_SMOOTH_AMOUNT_4X:
|
||||
iOffsetMult = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
m_pScaleBitmap->Clear();
|
||||
|
||||
if (!m_pFontRenderer.GetGlyph(m_pScaleBitmap, &pSlot->iHoriAdvance, &pSlot->iCharWidth, &pSlot->iCharHeight, pSlot->iCharOffsetX, pSlot->iCharOffsetY, 0, 0, cChar, fontHintParams))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
pSlot->iCharWidth >>= iOffsetMult >> 1;
|
||||
pSlot->iCharHeight >>= iOffsetMult >> 1;
|
||||
|
||||
m_pScaleBitmap->BlitScaledTo8(pSlot->pGlyphBitmap.GetBuffer(), 0, 0, m_pScaleBitmap->GetWidth(), m_pScaleBitmap->GetHeight(), 0, 0, pSlot->pGlyphBitmap.GetWidth(), pSlot->pGlyphBitmap.GetHeight(), pSlot->pGlyphBitmap.GetWidth());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_pFontRenderer.GetGlyph(&pSlot->pGlyphBitmap, &pSlot->iHoriAdvance, &pSlot->iCharWidth, &pSlot->iCharHeight, pSlot->iCharOffsetX, pSlot->iCharOffsetY, 0, 0, cChar, fontHintParams))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_iSmoothMethod == FONT_SMOOTH_BLUR)
|
||||
{
|
||||
pSlot->pGlyphBitmap.Blur(m_iSmoothAmount);
|
||||
}
|
||||
|
||||
pSlot->dwUsage = m_dwUsage;
|
||||
pSlot->cCurrentChar = cChar;
|
||||
pSlot->glyphSize = glyphSize;
|
||||
|
||||
m_pCacheTable.insert(AZStd::pair<CryFont::GlyphCache::CCacheTableKey, CCacheSlot*>(GetCacheSlotKey(cChar, glyphSize), pSlot));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CGlyphCache::UnCacheGlyph(uint32 cChar, const Vec2i& glyphSize)
|
||||
{
|
||||
CCacheTable::iterator pItor = m_pCacheTable.find(GetCacheSlotKey(cChar, glyphSize));
|
||||
|
||||
if (pItor != m_pCacheTable.end())
|
||||
{
|
||||
CCacheSlot* pSlot = pItor->second;
|
||||
|
||||
pSlot->Reset();
|
||||
|
||||
m_pCacheTable.erase(pItor);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphCache::GlyphCached(uint32 cChar, const Vec2i& glyphSize)
|
||||
{
|
||||
return (m_pCacheTable.find(GetCacheSlotKey(cChar, glyphSize)) != m_pCacheTable.end());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CCacheSlot* CGlyphCache::GetLRUSlot()
|
||||
{
|
||||
unsigned int dwMinUsage = 0xffffffff;
|
||||
CCacheSlot* pLRUSlot = 0;
|
||||
CCacheSlot* pSlot;
|
||||
|
||||
CCacheSlotListItor pItor = m_pSlotList.begin();
|
||||
|
||||
while (pItor != m_pSlotList.end())
|
||||
{
|
||||
pSlot = *pItor;
|
||||
|
||||
if (pSlot->dwUsage == 0)
|
||||
{
|
||||
return pSlot;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pSlot->dwUsage < dwMinUsage)
|
||||
{
|
||||
pLRUSlot = pSlot;
|
||||
dwMinUsage = pSlot->dwUsage;
|
||||
}
|
||||
}
|
||||
|
||||
pItor++;
|
||||
}
|
||||
|
||||
return pLRUSlot;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CCacheSlot* CGlyphCache::GetMRUSlot()
|
||||
{
|
||||
unsigned int dwMaxUsage = 0;
|
||||
CCacheSlot* pMRUSlot = 0;
|
||||
CCacheSlot* pSlot;
|
||||
|
||||
CCacheSlotListItor pItor = m_pSlotList.begin();
|
||||
|
||||
while (pItor != m_pSlotList.end())
|
||||
{
|
||||
pSlot = *pItor;
|
||||
|
||||
if (pSlot->dwUsage != 0)
|
||||
{
|
||||
if (pSlot->dwUsage > dwMaxUsage)
|
||||
{
|
||||
pMRUSlot = pSlot;
|
||||
dwMaxUsage = pSlot->dwUsage;
|
||||
}
|
||||
}
|
||||
|
||||
pItor++;
|
||||
}
|
||||
|
||||
return pMRUSlot;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphCache::GetGlyph(CGlyphBitmap** pGlyph, int* piHoriAdvance, int* piWidth, int* piHeight, AZ::s32& iCharOffsetX, AZ::s32& iCharOffsetY, uint32 cChar, const Vec2i& glyphSize, const CFFont::FontHintParams& fontHintParams)
|
||||
{
|
||||
CCacheTable::iterator pItor = m_pCacheTable.find(GetCacheSlotKey(cChar, glyphSize));
|
||||
|
||||
if (pItor == m_pCacheTable.end())
|
||||
{
|
||||
if (!PreCacheGlyph(cChar, glyphSize, fontHintParams))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
pItor = m_pCacheTable.find(GetCacheSlotKey(cChar, glyphSize));
|
||||
|
||||
pItor->second->dwUsage = m_dwUsage++;
|
||||
(*pGlyph) = &pItor->second->pGlyphBitmap;
|
||||
|
||||
if (piHoriAdvance)
|
||||
{
|
||||
*piHoriAdvance = pItor->second->iHoriAdvance;
|
||||
}
|
||||
|
||||
if (piWidth)
|
||||
{
|
||||
*piWidth = pItor->second->iCharWidth;
|
||||
}
|
||||
|
||||
if (piHeight)
|
||||
{
|
||||
*piHeight = pItor->second->iCharHeight;
|
||||
}
|
||||
|
||||
iCharOffsetX = pItor->second->iCharOffsetX;
|
||||
iCharOffsetY = pItor->second->iCharOffsetY;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
Vec2 CGlyphCache::GetKerning(uint32_t leftGlyph, uint32_t rightGlyph)
|
||||
{
|
||||
return m_pFontRenderer.GetKerning(leftGlyph, rightGlyph);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
float CGlyphCache::GetAscenderToHeightRatio()
|
||||
{
|
||||
return m_pFontRenderer.GetAscenderToHeightRatio();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphCache::CreateSlotList(int iListSize)
|
||||
{
|
||||
for (int i = 0; i < iListSize; i++)
|
||||
{
|
||||
CCacheSlot* pCacheSlot = new CCacheSlot;
|
||||
|
||||
if (!pCacheSlot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!pCacheSlot->pGlyphBitmap.Create(m_iGlyphBitmapWidth, m_iGlyphBitmapHeight))
|
||||
{
|
||||
delete pCacheSlot;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
pCacheSlot->Reset();
|
||||
|
||||
pCacheSlot->iCacheSlot = i;
|
||||
|
||||
m_pSlotList.push_back(pCacheSlot);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
int CGlyphCache::ReleaseSlotList()
|
||||
{
|
||||
CCacheSlotListItor pItor = m_pSlotList.begin();
|
||||
|
||||
while (pItor != m_pSlotList.end())
|
||||
{
|
||||
(*pItor)->pGlyphBitmap.Release();
|
||||
|
||||
delete (*pItor);
|
||||
|
||||
pItor = m_pSlotList.erase(pItor);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CryFont::GlyphCache::CCacheTableKey CGlyphCache::GetCacheSlotKey(uint32 cChar, const Vec2i& glyphSize) const
|
||||
{
|
||||
const Vec2i clampedGlyphSize = CFontTexture::ClampGlyphSize(glyphSize, m_iGlyphBitmapWidth, m_iGlyphBitmapHeight);
|
||||
return CryFont::GlyphCache::CCacheTableKey(clampedGlyphSize, cChar);
|
||||
}
|
||||
|
||||
#endif // #if !defined(USE_NULLFONT_ALWAYS)
|
||||
@@ -1,200 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
// Purpose:
|
||||
// - Manage and cache glyphs, retrieving them from the renderer as needed
|
||||
|
||||
#ifndef CRYINCLUDE_CRYFONT_GLYPHCACHE_H
|
||||
#define CRYINCLUDE_CRYFONT_GLYPHCACHE_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#include <vector>
|
||||
#include "GlyphBitmap.h"
|
||||
#include "FontRenderer.h"
|
||||
#include "CryFont.h"
|
||||
#include <StlUtils.h>
|
||||
|
||||
//! Glyph cache slots store the bitmap buffer and glyph metadata from FreeType.
|
||||
//!
|
||||
//! This bitmap buffer is eventually copied to a CFontTexture texture buffer.
|
||||
//! A glyph cache slot bitmap buffer only holds a single glyph, whereas the
|
||||
//! CFontTexture stores multiple glyphs in a grid (row/col) format.
|
||||
typedef struct CCacheSlot
|
||||
{
|
||||
Vec2i glyphSize = CCryFont::defaultGlyphSize; //!< The render resolution of the glyph in the glyph bitmap
|
||||
unsigned int dwUsage;
|
||||
int iCacheSlot;
|
||||
int iHoriAdvance; //!< Advance width. See FT_Glyph_Metrics::horiAdvance.
|
||||
uint32 cCurrentChar;
|
||||
|
||||
uint8 iCharWidth; //!< Glyph width (in pixel)
|
||||
uint8 iCharHeight; //!< Glyph height (in pixel)
|
||||
AZ::s32 iCharOffsetX; //!< Glyph's left-side bearing (in pixels). See FT_GlyphSlotRec::bitmap_left.
|
||||
AZ::s32 iCharOffsetY; //!< Glyph's top bearing (in pixels). See FT_GlyphSlotRec::bitmap_top.
|
||||
|
||||
CGlyphBitmap pGlyphBitmap; //!< Contains a buffer storing a copy of the glyph from FreeType
|
||||
|
||||
void Reset()
|
||||
{
|
||||
dwUsage = 0;
|
||||
cCurrentChar = ~0;
|
||||
|
||||
iCharWidth = 0;
|
||||
iCharHeight = 0;
|
||||
iCharOffsetX = 0;
|
||||
iCharOffsetY = 0;
|
||||
|
||||
pGlyphBitmap.Clear();
|
||||
}
|
||||
|
||||
void GetMemoryUsage(ICrySizer* pSizer) const
|
||||
{
|
||||
pSizer->AddObject(this, sizeof(*this));
|
||||
pSizer->AddObject(pGlyphBitmap);
|
||||
}
|
||||
} CCacheSlot;
|
||||
|
||||
namespace CryFont
|
||||
{
|
||||
namespace GlyphCache
|
||||
{
|
||||
//! Height and width pair for glyph size mapping
|
||||
typedef Vec2i CCacheTableGlyphSizeType;
|
||||
|
||||
//! Pair for mapping a height and width size to a UTF32 character/glyph
|
||||
typedef AZStd::pair<CCacheTableGlyphSizeType, uint32> CCacheTableKey;
|
||||
|
||||
//! Hasher for glyph cache table keys (glyphsize-char code pair)
|
||||
//!
|
||||
//! Instead of creating our own custom hash, the types are broken down to their
|
||||
//! native types (ints) and passed to existing hashes that handle those types.
|
||||
struct HashGlyphCacheTableKey
|
||||
{
|
||||
typedef CCacheTableKey ArgumentType;
|
||||
typedef AZStd::size_t ResultType;
|
||||
typedef AZStd::pair<int32, int32> Int32Pair;
|
||||
typedef AZStd::pair<Int32Pair, uint32> Int32PairU32Pair;
|
||||
ResultType operator()(const ArgumentType& value) const
|
||||
{
|
||||
AZStd::hash<Int32PairU32Pair> pairHash;
|
||||
return pairHash(Int32PairU32Pair(Int32Pair(value.first.x, value.first.y), value.second));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//! Maps size-speicifc UTF32 glyphs to their corresponding cache slots
|
||||
typedef AZStd::unordered_map<CryFont::GlyphCache::CCacheTableKey, CCacheSlot*, CryFont::GlyphCache::HashGlyphCacheTableKey> CCacheTable;
|
||||
|
||||
typedef std::vector<CCacheSlot*> CCacheSlotList;
|
||||
typedef std::vector<CCacheSlot*>::iterator CCacheSlotListItor;
|
||||
|
||||
|
||||
#ifdef WIN64
|
||||
#undef GetCharWidth
|
||||
#undef GetCharHeight
|
||||
#endif
|
||||
|
||||
//! The glyph cache maps UTF32 codepoints to their corresponding FreeType data.
|
||||
//!
|
||||
//! This cache is used to associate font glyph info (read from FreeType) with
|
||||
//! UTF32 codepoints. Ultimately the glyph info will be read into a font texture
|
||||
//! (CFontTexture) to avoid future FreeType lookups.
|
||||
//!
|
||||
//! If a CFontTexture is missing a glyph that is currently stored in the glyph
|
||||
//! cache, the cached data can be returned instead of having to be rendered from
|
||||
//! FreeType again.
|
||||
//!
|
||||
//! \sa CFontTexture
|
||||
class CGlyphCache
|
||||
{
|
||||
public:
|
||||
CGlyphCache();
|
||||
~CGlyphCache();
|
||||
|
||||
int Create(int iCacheSize, int iGlyphBitmapWidth, int iGlyphBitmapHeight, int iSmoothMethod, int iSmoothAmount, float sizeRatio);
|
||||
int Release();
|
||||
|
||||
int LoadFontFromFile(const string& szFileName);
|
||||
int LoadFontFromMemory(unsigned char* pFileBuffer, int iDataSize);
|
||||
int ReleaseFont();
|
||||
|
||||
int SetEncoding(FT_Encoding pEncoding) { return m_pFontRenderer.SetEncoding(pEncoding); };
|
||||
FT_Encoding GetEncoding() { return m_pFontRenderer.GetEncoding(); };
|
||||
|
||||
int GetGlyphBitmapSize(int* pWidth, int* pHeight);
|
||||
void SetGlyphBitmapSize(int width, int height, float sizeRatio);
|
||||
|
||||
int PreCacheGlyph(uint32 cChar, const Vec2i& glyphSize = CCryFont::defaultGlyphSize, const CFFont::FontHintParams& glyphFlags = CFFont::FontHintParams());
|
||||
int UnCacheGlyph(uint32 cChar, const Vec2i& glyphSize = CCryFont::defaultGlyphSize);
|
||||
int GlyphCached(uint32 cChar, const Vec2i& glyphSize = CCryFont::defaultGlyphSize);
|
||||
|
||||
CCacheSlot* GetLRUSlot();
|
||||
CCacheSlot* GetMRUSlot();
|
||||
|
||||
//! Obtains glyph information for the given UTF32 codepoint.
|
||||
//! This information is obtained from a CCacheSlot that corresponds to
|
||||
//! the given codepoint. If the codepoint doesn't exist within the cache
|
||||
//! table (m_pCacheTable), then the information is obtain from FreeType
|
||||
//! directly via CFontRenderer.
|
||||
//!
|
||||
//! Ultimately the glyph bitmap is copied into a font texture
|
||||
//! (CFontTexture). Once the glyph is copied into the font texture then
|
||||
//! the font texture is referenced directly rather than relying on the
|
||||
//! glyph cache or FreeType.
|
||||
//!
|
||||
//! \sa CFontRenderer::GetGlyph, CFontTexture::UpdateSlot
|
||||
int GetGlyph(CGlyphBitmap** pGlyph, int* piHoriAdvance, int* piWidth, int* piHeight, AZ::s32& iCharOffsetX, AZ::s32& iCharOffsetY, uint32 cChar, const Vec2i& glyphSize = CCryFont::defaultGlyphSize, const CFFont::FontHintParams& glyphFlags = CFFont::FontHintParams());
|
||||
|
||||
void GetMemoryUsage(ICrySizer* pSizer) const
|
||||
{
|
||||
pSizer->AddObject(m_pSlotList);
|
||||
//pSizer->AddContainer(m_pCacheTable);
|
||||
pSizer->AddObject(m_pScaleBitmap);
|
||||
pSizer->AddObject(m_pFontRenderer);
|
||||
}
|
||||
|
||||
bool GetMonospaced() const { return m_pFontRenderer.GetMonospaced(); }
|
||||
|
||||
Vec2 GetKerning(uint32_t leftGlyph, uint32_t rightGlyph);
|
||||
|
||||
float GetAscenderToHeightRatio();
|
||||
|
||||
private:
|
||||
|
||||
//! Returns a key for the cache table where the given char is mapped at the given size.
|
||||
CryFont::GlyphCache::CCacheTableKey GetCacheSlotKey(uint32 cChar, const Vec2i& glyphSize = CCryFont::defaultGlyphSize) const;
|
||||
|
||||
int CreateSlotList(int iListSize);
|
||||
int ReleaseSlotList();
|
||||
|
||||
CCacheSlotList m_pSlotList;
|
||||
CCacheTable m_pCacheTable;
|
||||
|
||||
int m_iGlyphBitmapWidth;
|
||||
int m_iGlyphBitmapHeight;
|
||||
|
||||
int m_iSmoothMethod;
|
||||
int m_iSmoothAmount;
|
||||
|
||||
CGlyphBitmap* m_pScaleBitmap;
|
||||
|
||||
CFontRenderer m_pFontRenderer;
|
||||
|
||||
unsigned int m_dwUsage;
|
||||
};
|
||||
|
||||
#endif // #if !defined(USE_NULLFONT_ALWAYS)
|
||||
|
||||
#endif // CRYINCLUDE_CRYFONT_GLYPHCACHE_H
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Create the font interface.
|
||||
|
||||
|
||||
#include "CryFont_precompiled.h"
|
||||
|
||||
#include <IEngineModule.h>
|
||||
#include <CryExtension/ICryFactory.h>
|
||||
#include <CryExtension/Impl/ClassWeaver.h>
|
||||
|
||||
#include "CryFont.h"
|
||||
#if defined(USE_NULLFONT)
|
||||
#include "NullFont.h"
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct CSystemEventListner_Font
|
||||
: public ISystemEventListener
|
||||
{
|
||||
public:
|
||||
virtual void OnSystemEvent(ESystemEvent event, [[maybe_unused]] UINT_PTR wparam, [[maybe_unused]] UINT_PTR lparam)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case ESYSTEM_EVENT_LEVEL_POST_UNLOAD:
|
||||
{
|
||||
STLALLOCATOR_CLEANUP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
static CSystemEventListner_Font g_system_event_listener_font;
|
||||
|
||||
///////////////////////////////////////////////
|
||||
extern "C" ICryFont * CreateCryFontInterface(ISystem * pSystem)
|
||||
{
|
||||
ModuleInitISystem(pSystem, "CryFont");
|
||||
|
||||
if (gEnv->IsDedicated())
|
||||
{
|
||||
#if defined(USE_NULLFONT)
|
||||
return new CCryNullFont();
|
||||
#else
|
||||
// The NULL font implementation must be present for all platforms
|
||||
// supporting running as a pure dedicated server.
|
||||
pSystem->GetILog()->LogError("Missing NULL font implementation for dedicated server");
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(USE_NULLFONT) && defined(USE_NULLFONT_ALWAYS)
|
||||
return new CCryNullFont();
|
||||
#else
|
||||
pSystem->GetISystemEventDispatcher()->RegisterListener(&g_system_event_listener_font);
|
||||
return new CCryFont(pSystem);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CEngineModule_CryFont
|
||||
: public IEngineModule
|
||||
{
|
||||
CRYINTERFACE_SIMPLE(IEngineModule)
|
||||
CRYGENERATE_SINGLETONCLASS(CEngineModule_CryFont, "EngineModule_CryFont", 0x6758643f43214957, 0x9b920d898d31f434)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual const char* GetName() const {
|
||||
return "CryFont";
|
||||
};
|
||||
virtual const char* GetCategory() const { return "CryEngine"; };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual bool Initialize(SSystemGlobalEnvironment& env, [[maybe_unused]] const SSystemInitParams& initParams)
|
||||
{
|
||||
ISystem* pSystem = env.pSystem;
|
||||
env.pCryFont = CreateCryFontInterface(pSystem);
|
||||
return env.pCryFont != 0;
|
||||
}
|
||||
};
|
||||
|
||||
CRYREGISTER_SINGLETON_CLASS(CEngineModule_CryFont)
|
||||
|
||||
CEngineModule_CryFont::CEngineModule_CryFont()
|
||||
{
|
||||
};
|
||||
|
||||
CEngineModule_CryFont::~CEngineModule_CryFont()
|
||||
{
|
||||
};
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Dummy font implementation (dedicated server)
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYFONT_NULLFONT_H
|
||||
#define CRYINCLUDE_CRYFONT_NULLFONT_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#if defined(USE_NULLFONT)
|
||||
|
||||
#include <IFont.h>
|
||||
|
||||
class CNullFont
|
||||
: public IFFont
|
||||
{
|
||||
public:
|
||||
CNullFont() {}
|
||||
virtual ~CNullFont() {}
|
||||
|
||||
virtual int32 AddRef() { return 0; };
|
||||
virtual int32 Release() { return 0; };
|
||||
|
||||
virtual bool Load([[maybe_unused]] const char* pFontFilePath, [[maybe_unused]] unsigned int width, [[maybe_unused]] unsigned int height, [[maybe_unused]] unsigned int widthNumSlots, [[maybe_unused]] unsigned int heightNumSlots, [[maybe_unused]] unsigned int flags, [[maybe_unused]] float sizeRatio) { return true; }
|
||||
virtual bool Load([[maybe_unused]] const char* pXMLFile) { return true; }
|
||||
virtual void Free() {}
|
||||
|
||||
virtual void DrawString([[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] const char* pStr, [[maybe_unused]] const bool asciiMultiLine, [[maybe_unused]] const STextDrawContext& ctx) {}
|
||||
virtual void DrawString([[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] float z, [[maybe_unused]] const char* pStr, [[maybe_unused]] const bool asciiMultiLine, [[maybe_unused]] const STextDrawContext& ctx) {}
|
||||
|
||||
virtual void DrawStringW([[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] const wchar_t* pStr, [[maybe_unused]] const bool asciiMultiLine, [[maybe_unused]] const STextDrawContext& ctx) {}
|
||||
virtual void DrawStringW([[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] float z, [[maybe_unused]] const wchar_t* pStr, [[maybe_unused]] const bool asciiMultiLine, [[maybe_unused]] const STextDrawContext& ctx) {}
|
||||
|
||||
virtual Vec2 GetTextSize([[maybe_unused]] const char* pStr, [[maybe_unused]] const bool asciiMultiLine, [[maybe_unused]] const STextDrawContext& ctx) { return Vec2(0.0f, 0.0f); }
|
||||
virtual Vec2 GetTextSizeW([[maybe_unused]] const wchar_t* pStr, [[maybe_unused]] const bool asciiMultiLine, [[maybe_unused]] const STextDrawContext& ctx) { return Vec2(0.0f, 0.0f); }
|
||||
|
||||
virtual size_t GetTextLength([[maybe_unused]] const char* pStr, [[maybe_unused]] const bool asciiMultiLine) const { return 0; }
|
||||
virtual size_t GetTextLengthW([[maybe_unused]] const wchar_t* pStr, [[maybe_unused]] const bool asciiMultiLine) const { return 0; }
|
||||
|
||||
virtual void WrapText(string& result, [[maybe_unused]] float maxWidth, const char* pStr, [[maybe_unused]] const STextDrawContext& ctx) { result = pStr; }
|
||||
virtual void WrapTextW(wstring& result, [[maybe_unused]] float maxWidth, const wchar_t* pStr, [[maybe_unused]] const STextDrawContext& ctx) { result = pStr; }
|
||||
|
||||
virtual void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const {}
|
||||
|
||||
virtual void GetGradientTextureCoord([[maybe_unused]] float& minU, [[maybe_unused]] float& minV, [[maybe_unused]] float& maxU, [[maybe_unused]] float& maxV) const {}
|
||||
|
||||
virtual unsigned int GetEffectId([[maybe_unused]] const char* pEffectName) const { return 0; }
|
||||
virtual unsigned int GetNumEffects() const { return 0; }
|
||||
virtual const char* GetEffectName([[maybe_unused]] unsigned int effectId) const { return nullptr; }
|
||||
virtual Vec2 GetMaxEffectOffset([[maybe_unused]] unsigned int effectId) const { return Vec2(); }
|
||||
virtual bool DoesEffectHaveTransparency([[maybe_unused]] unsigned int effectId) const { return false; }
|
||||
|
||||
virtual void AddCharsToFontTexture([[maybe_unused]] const char* pChars, [[maybe_unused]] int glyphSizeX, [[maybe_unused]] int glyphSizeY) override {}
|
||||
virtual Vec2 GetKerning([[maybe_unused]] uint32_t leftGlyph, [[maybe_unused]] uint32_t rightGlyph, [[maybe_unused]] const STextDrawContext& ctx) const override { return Vec2(); }
|
||||
virtual float GetAscender([[maybe_unused]] const STextDrawContext& ctx) const override { return 0.0f; }
|
||||
virtual float GetBaseline([[maybe_unused]] const STextDrawContext& ctx) const override { return 0.0f; }
|
||||
virtual float GetSizeRatio() const override { return IFFontConstants::defaultSizeRatio; }
|
||||
virtual uint32 GetNumQuadsForText([[maybe_unused]] const char* pStr, [[maybe_unused]] const bool asciiMultiLine, [[maybe_unused]] const STextDrawContext& ctx) { return 0; }
|
||||
virtual uint32 WriteTextQuadsToBuffers([[maybe_unused]] SVF_P2F_C4B_T2F_F4B* verts, [[maybe_unused]] uint16* indices, [[maybe_unused]] uint32 maxQuads, [[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] float z, [[maybe_unused]] const char* pStr, [[maybe_unused]] const bool asciiMultiLine, [[maybe_unused]] const STextDrawContext& ctx) { return 0; }
|
||||
virtual int GetFontTextureId() { return -1; }
|
||||
virtual uint32 GetFontTextureVersion() { return 0; }
|
||||
};
|
||||
|
||||
class CCryNullFont
|
||||
: public ICryFont
|
||||
{
|
||||
public:
|
||||
virtual void Release() {}
|
||||
virtual IFFont* NewFont([[maybe_unused]] const char* pFontName) { return &ms_nullFont; }
|
||||
virtual IFFont* GetFont([[maybe_unused]] const char* pFontName) const { return &ms_nullFont; }
|
||||
virtual FontFamilyPtr LoadFontFamily([[maybe_unused]] const char* pFontFamilyName) override { CRY_ASSERT(false); return nullptr; }
|
||||
virtual FontFamilyPtr GetFontFamily([[maybe_unused]] const char* pFontFamilyName) override { CRY_ASSERT(false); return nullptr; }
|
||||
virtual void AddCharsToFontTextures(FontFamilyPtr pFontFamily, [[maybe_unused]] const char* pChars, [[maybe_unused]] int glyphSizeX, [[maybe_unused]] int glyphSizeY) override {};
|
||||
virtual void SetRendererProperties([[maybe_unused]] IRenderer* pRenderer) {}
|
||||
virtual void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const {}
|
||||
virtual string GetLoadedFontNames() const { return ""; }
|
||||
virtual void OnLanguageChanged() override { }
|
||||
virtual void ReloadAllFonts() override { }
|
||||
|
||||
private:
|
||||
static CNullFont ms_nullFont;
|
||||
};
|
||||
|
||||
#endif // USE_NULLFONT
|
||||
|
||||
#endif // CRYINCLUDE_CRYFONT_NULLFONT_H
|
||||
@@ -1,16 +0,0 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
# Platform specific cmake file for configuring target compiler/link properties
|
||||
# based on the active platform
|
||||
# NOTE: functions in cmake are global, therefore adding functions to this file
|
||||
# is being avoided to prevent overriding functions declared in other targets platfrom
|
||||
# specific cmake files
|
||||
@@ -1,33 +0,0 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(FILES
|
||||
CryFont.cpp
|
||||
FFont.cpp
|
||||
FFontXML.cpp
|
||||
FontRenderer.cpp
|
||||
FontTexture.cpp
|
||||
GlyphBitmap.cpp
|
||||
GlyphCache.cpp
|
||||
ICryFont.cpp
|
||||
NullFont.cpp
|
||||
CryFont.h
|
||||
FBitmap.h
|
||||
FFont.h
|
||||
FontRenderer.h
|
||||
FontTexture.h
|
||||
GlyphBitmap.h
|
||||
GlyphCache.h
|
||||
NullFont.h
|
||||
resource.h
|
||||
CryFont_precompiled.h
|
||||
CryFont_precompiled.cpp
|
||||
)
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#define VS_VERSION_INFO 1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -90,8 +90,6 @@ ly_add_target(
|
||||
AZ::AzCore
|
||||
Legacy::CryCommon
|
||||
Legacy::CryCommon.EngineSettings.Static
|
||||
RUNTIME_DEPENDENCIES
|
||||
Legacy::CryFont
|
||||
)
|
||||
|
||||
################################################################################
|
||||
|
||||
@@ -52,11 +52,7 @@
|
||||
# define cpuid(op, eax, ebx, ecx, edx) __asm__("cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : "a" (op) : "cc");
|
||||
#endif
|
||||
|
||||
#if defined(AZ_MONOLITHIC_BUILD)
|
||||
extern int g_CpuFlags;
|
||||
#else
|
||||
int g_CpuFlags;
|
||||
#endif
|
||||
|
||||
struct SAutoMaxPriority
|
||||
{
|
||||
|
||||
@@ -676,17 +676,11 @@ private:
|
||||
//! @name Initialization routines
|
||||
//@{
|
||||
bool InitConsole();
|
||||
bool InitRenderer(WIN_HINSTANCE hinst, WIN_HWND hwnd, const SSystemInitParams& initParams);
|
||||
|
||||
bool InitFont(const SSystemInitParams& initParams);
|
||||
bool InitFileSystem();
|
||||
bool InitFileSystem_LoadEngineFolders(const SSystemInitParams& initParams);
|
||||
bool InitStreamEngine();
|
||||
bool Init3DEngine(const SSystemInitParams& initParams);
|
||||
bool InitAudioSystem(const SSystemInitParams& initParams);
|
||||
bool InitShine(const SSystemInitParams& initParams);
|
||||
bool OpenRenderLibrary(int type, const SSystemInitParams& initParams);
|
||||
bool OpenRenderLibrary(const char* t_rend, const SSystemInitParams& initParams);
|
||||
|
||||
//@}
|
||||
|
||||
@@ -738,9 +732,6 @@ private:
|
||||
bool GetWinGameFolder(char* szMyDocumentsPath, int maxPathSize);
|
||||
#endif
|
||||
|
||||
//! \brief Initializes the given IFFont member variable with the given name (internal use only).
|
||||
bool LoadFontInternal(IFFont*& font, const string& fontName);
|
||||
|
||||
public:
|
||||
void EnableFloatExceptions(int type);
|
||||
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
#include <StringUtils.h>
|
||||
#include <IThreadManager.h>
|
||||
|
||||
#include "CryFontBus.h"
|
||||
|
||||
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
|
||||
@@ -247,24 +245,6 @@ CUNIXConsole* pUnixConsole;
|
||||
|
||||
#define LOCALIZATION_TRANSLATIONS_LIST_FILE_NAME "Libs/Localization/localization.xml"
|
||||
|
||||
#define LOAD_LEGACY_RENDERER_FOR_EDITOR false // If you set this to true you must also set 'ed_useAtomNativeViewport' to false (see /Code/Sandbox/Editor/ViewManager.cpp)
|
||||
#define LOAD_LEGACY_RENDERER_FOR_LAUNCHER false
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Where possible, these are defaults used to initialize cvars
|
||||
// System.cfg can then be used to override them
|
||||
// This includes the Game DLL, although it is loaded elsewhere
|
||||
|
||||
#define DLL_FONT "CryFont"
|
||||
#define DLL_3DENGINE "Cry3DEngine"
|
||||
#define DLL_RENDERER_DX9 "CryRenderD3D9"
|
||||
#define DLL_RENDERER_DX11 "CryRenderD3D11"
|
||||
#define DLL_RENDERER_DX12 "CryRenderD3D12"
|
||||
#define DLL_RENDERER_METAL "CryRenderMetal"
|
||||
#define DLL_RENDERER_GL "CryRenderGL"
|
||||
#define DLL_RENDERER_NULL "CryRenderNULL"
|
||||
#define DLL_SHINE "LyShine"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#if defined(WIN32) || defined(LINUX) || defined(APPLE)
|
||||
# define DLL_MODULE_INIT_ISYSTEM "ModuleInitISystem"
|
||||
@@ -1079,58 +1059,6 @@ void CSystem::ShutdownModuleLibraries()
|
||||
#endif // !defined(AZ_MONOLITHIC_BUILD)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CSystem::OpenRenderLibrary([[maybe_unused]] const char* t_rend, const SSystemInitParams& initParams)
|
||||
{
|
||||
LOADING_TIME_PROFILE_SECTION(GetISystem());
|
||||
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_6
|
||||
#include AZ_RESTRICTED_FILE(SystemInit_cpp)
|
||||
#endif
|
||||
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
|
||||
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
|
||||
#else
|
||||
|
||||
if (gEnv->IsDedicated())
|
||||
{
|
||||
return OpenRenderLibrary(R_NULL_RENDERER, initParams);
|
||||
}
|
||||
|
||||
if (AZ::Interface<AzFramework::AtomActiveInterface>::Get())
|
||||
{
|
||||
return OpenRenderLibrary(R_DX11_RENDERER, initParams);
|
||||
}
|
||||
else if (azstricmp(t_rend, "DX9") == 0)
|
||||
{
|
||||
return OpenRenderLibrary(R_DX9_RENDERER, initParams);
|
||||
}
|
||||
else if (azstricmp(t_rend, "DX11") == 0)
|
||||
{
|
||||
return OpenRenderLibrary(R_DX11_RENDERER, initParams);
|
||||
}
|
||||
else if (azstricmp(t_rend, "DX12") == 0)
|
||||
{
|
||||
return OpenRenderLibrary(R_DX12_RENDERER, initParams);
|
||||
}
|
||||
else if (azstricmp(t_rend, "GL") == 0)
|
||||
{
|
||||
return OpenRenderLibrary(R_GL_RENDERER, initParams);
|
||||
}
|
||||
else if (azstricmp(t_rend, "METAL") == 0)
|
||||
{
|
||||
return OpenRenderLibrary(R_METAL_RENDERER, initParams);
|
||||
}
|
||||
else if (azstricmp(t_rend, "NULL") == 0)
|
||||
{
|
||||
return OpenRenderLibrary(R_NULL_RENDERER, initParams);
|
||||
}
|
||||
|
||||
AZ_Assert(false, "Unknown renderer type: %s", t_rend);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1220,126 +1148,6 @@ wstring GetErrorStringUnsupportedGPU(const char* gpuName, unsigned int gpuVendor
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CSystem::OpenRenderLibrary(int type, const SSystemInitParams& initParams)
|
||||
{
|
||||
LOADING_TIME_PROFILE_SECTION;
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
if (!gEnv->IsDedicated())
|
||||
{
|
||||
unsigned int gpuVendorId = 0, gpuDeviceId = 0, totVidMem = 0;
|
||||
char gpuName[256];
|
||||
Win32SysInspect::DXFeatureLevel featureLevel = Win32SysInspect::DXFL_Undefined;
|
||||
Win32SysInspect::GetGPUInfo(gpuName, sizeof(gpuName), gpuVendorId, gpuDeviceId, totVidMem, featureLevel);
|
||||
|
||||
if (m_env.IsEditor())
|
||||
{
|
||||
#if defined(EXTERNAL_CRASH_REPORTING)
|
||||
CrashHandler::CrashHandlerBase::AddAnnotation("dx.feature.level", Win32SysInspect::GetFeatureLevelAsString(featureLevel));
|
||||
CrashHandler::CrashHandlerBase::AddAnnotation("gpu.name", gpuName);
|
||||
CrashHandler::CrashHandlerBase::AddAnnotation("gpu.vendorId", std::to_string(gpuVendorId));
|
||||
CrashHandler::CrashHandlerBase::AddAnnotation("gpu.deviceId", std::to_string(gpuDeviceId));
|
||||
CrashHandler::CrashHandlerBase::AddAnnotation("gpu.memory", std::to_string(totVidMem));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (featureLevel < Win32SysInspect::DXFL_11_0)
|
||||
{
|
||||
const char logMsgFmt[] ("Unsupported GPU configuration!\n- %s (vendor = 0x%.4x, device = 0x%.4x)\n- Dedicated video memory: %d MB\n- Feature level: %s\n");
|
||||
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, logMsgFmt, gpuName, gpuVendorId, gpuDeviceId, totVidMem >> 20, GetFeatureLevelAsString(featureLevel));
|
||||
|
||||
#if !defined(_RELEASE)
|
||||
const bool allowPrompts = m_env.pSystem->GetICmdLine()->FindArg(eCLAT_Pre, "noprompt") == 0;
|
||||
#else
|
||||
const bool allowPrompts = true;
|
||||
#endif // !defined(_RELEASE)
|
||||
if (allowPrompts)
|
||||
{
|
||||
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "Asking user if they wish to continue...");
|
||||
const int mbRes = MessageBoxW(0, GetErrorStringUnsupportedGPU(gpuName, gpuVendorId, gpuDeviceId).c_str(), L"Open 3D Engine", MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON2 | MB_DEFAULT_DESKTOP_ONLY);
|
||||
if (mbRes == IDCANCEL)
|
||||
{
|
||||
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "User chose to cancel startup due to unsupported GPU.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(_RELEASE)
|
||||
const bool obeyGPUCheck = m_env.pSystem->GetICmdLine()->FindArg(eCLAT_Pre, "anygpu") == 0;
|
||||
#else
|
||||
const bool obeyGPUCheck = true;
|
||||
#endif // !defined(_RELEASE)
|
||||
if (obeyGPUCheck)
|
||||
{
|
||||
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "No prompts allowed and unsupported GPU check active. Treating unsupported GPU as error and exiting.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "User chose to continue despite unsupported GPU!");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_7
|
||||
#include AZ_RESTRICTED_FILE(SystemInit_cpp)
|
||||
#endif
|
||||
|
||||
if (gEnv->IsDedicated())
|
||||
{
|
||||
type = R_NULL_RENDERER;
|
||||
}
|
||||
const char* libname = "";
|
||||
if (AZ::Interface<AzFramework::AtomActiveInterface>::Get())
|
||||
{
|
||||
libname = DLL_RENDERER_NULL;
|
||||
}
|
||||
else if (type == R_DX9_RENDERER)
|
||||
{
|
||||
libname = DLL_RENDERER_DX9;
|
||||
}
|
||||
else if (type == R_DX11_RENDERER)
|
||||
{
|
||||
libname = DLL_RENDERER_DX11;
|
||||
}
|
||||
else if (type == R_DX12_RENDERER)
|
||||
{
|
||||
libname = DLL_RENDERER_DX12;
|
||||
}
|
||||
else if (type == R_NULL_RENDERER)
|
||||
{
|
||||
libname = DLL_RENDERER_NULL;
|
||||
}
|
||||
else if (type == R_GL_RENDERER)
|
||||
{
|
||||
libname = DLL_RENDERER_GL;
|
||||
}
|
||||
else if (type == R_METAL_RENDERER)
|
||||
{
|
||||
libname = DLL_RENDERER_METAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "Renderer did not initialize correctly; no valid renderer specified.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!InitializeEngineModule(libname, "EngineModule_CryRenderer", initParams))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_env.pRenderer)
|
||||
{
|
||||
AZ_Assert(false, "Renderer did not initialize correctly; it could not be found in the system environment.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
bool CSystem::InitConsole()
|
||||
@@ -1391,123 +1199,6 @@ ICVar* CSystem::attachVariable (const char* szVarName, int* pContainer, const ch
|
||||
return pVar;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
bool CSystem::InitRenderer(WIN_HINSTANCE hinst, WIN_HWND hwnd, const SSystemInitParams& initParams)
|
||||
{
|
||||
LOADING_TIME_PROFILE_SECTION(GetISystem());
|
||||
|
||||
if (m_pUserCallback)
|
||||
{
|
||||
m_pUserCallback->OnInitProgress("Initializing Renderer...");
|
||||
}
|
||||
|
||||
if (m_bEditor)
|
||||
{
|
||||
m_env.pConsole->GetCVar("r_Width");
|
||||
|
||||
// save current screen width/height/bpp, so they can be restored on shutdown
|
||||
m_iWidth = m_env.pConsole->GetCVar("r_Width")->GetIVal();
|
||||
m_iHeight = m_env.pConsole->GetCVar("r_Height")->GetIVal();
|
||||
m_iColorBits = m_env.pConsole->GetCVar("r_ColorBits")->GetIVal();
|
||||
}
|
||||
|
||||
if (!OpenRenderLibrary(m_rDriver->GetString(), initParams))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(AZ_PLATFORM_IOS) || defined(AZ_PLATFORM_ANDROID)
|
||||
if (m_rWidthAndHeightAsFractionOfScreenSize->GetFlags() & VF_WASINCONFIG)
|
||||
{
|
||||
int displayWidth = 0;
|
||||
int displayHeight = 0;
|
||||
if (GetPrimaryPhysicalDisplayDimensions(displayWidth, displayHeight))
|
||||
{
|
||||
// Ideally we would probably want to clamp this at the source,
|
||||
// but I don't believe cvars support specifying a valid range.
|
||||
float scaleFactor = 1.0f;
|
||||
|
||||
if(IsTablet())
|
||||
{
|
||||
scaleFactor = AZ::GetClamp(m_rTabletWidthAndHeightAsFractionOfScreenSize->GetFVal(), 0.1f, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
scaleFactor = AZ::GetClamp(m_rWidthAndHeightAsFractionOfScreenSize->GetFVal(), 0.1f, 1.0f);
|
||||
}
|
||||
|
||||
displayWidth *= scaleFactor;
|
||||
displayHeight *= scaleFactor;
|
||||
|
||||
const int maxWidth = m_rMaxWidth->GetIVal();
|
||||
if (maxWidth > 0 && maxWidth < displayWidth)
|
||||
{
|
||||
const float widthScaleFactor = static_cast<float>(maxWidth) / static_cast<float>(displayWidth);
|
||||
displayWidth *= widthScaleFactor;
|
||||
displayHeight *= widthScaleFactor;
|
||||
}
|
||||
|
||||
const int maxHeight = m_rMaxHeight->GetIVal();
|
||||
if (maxHeight > 0 && maxHeight < displayHeight)
|
||||
{
|
||||
const float heightScaleFactor = static_cast<float>(maxHeight) / static_cast<float>(displayHeight);
|
||||
displayWidth *= heightScaleFactor;
|
||||
displayHeight *= heightScaleFactor;
|
||||
}
|
||||
|
||||
m_rWidth->Set(displayWidth);
|
||||
m_rHeight->Set(displayHeight);
|
||||
}
|
||||
}
|
||||
#endif // defined(AZ_PLATFORM_IOS) || defined(AZ_PLATFORM_ANDROID)
|
||||
|
||||
if (m_env.pRenderer)
|
||||
{
|
||||
// This is crucial as textures suffix are hard coded to context and we need to initialize
|
||||
// the texture semantics to look it up.
|
||||
m_env.pRenderer->InitTexturesSemantics();
|
||||
|
||||
#ifdef WIN32
|
||||
SCustomRenderInitArgs args;
|
||||
args.appStartedFromMediaCenter = strstr(initParams.szSystemCmdLine, "ReLaunchMediaCenter") != 0;
|
||||
|
||||
m_hWnd = m_env.pRenderer->Init(0, 0, m_rWidth->GetIVal(), m_rHeight->GetIVal(), m_rColorBits->GetIVal(), m_rDepthBits->GetIVal(), m_rStencilBits->GetIVal(), m_rFullscreen->GetIVal() ? true : false, initParams.bEditor, hinst, hwnd, false, &args, initParams.bShaderCacheGen);
|
||||
//Timur, Not very clean code, we need to push new hwnd value to the system init params, so other modules can used when initializing.
|
||||
(const_cast<SSystemInitParams*>(&initParams))->hWnd = m_hWnd;
|
||||
|
||||
|
||||
bool retVal = (initParams.bShaderCacheGen || m_hWnd != 0);
|
||||
AZ_Assert(retVal, "Renderer failed to initialize correctly.");
|
||||
return retVal;
|
||||
#else // WIN32
|
||||
WIN_HWND h = m_env.pRenderer->Init(0, 0, m_rWidth->GetIVal(), m_rHeight->GetIVal(), m_rColorBits->GetIVal(), m_rDepthBits->GetIVal(), m_rStencilBits->GetIVal(), m_rFullscreen->GetIVal() ? true : false, initParams.bEditor, hinst, hwnd, false, nullptr, initParams.bShaderCacheGen);
|
||||
|
||||
#if (defined(LINUX) && !defined(AZ_PLATFORM_ANDROID))
|
||||
return true;
|
||||
#define AZ_RESTRICTED_SECTION_IMPLEMENTED
|
||||
#elif defined(AZ_RESTRICTED_PLATFORM)
|
||||
#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_8
|
||||
#include AZ_RESTRICTED_FILE(SystemInit_cpp)
|
||||
#endif
|
||||
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
|
||||
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
|
||||
#else
|
||||
bool retVal = (initParams.bShaderCacheGen || h != 0);
|
||||
if (retVal)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
AZ_Assert(false, "Renderer failed to initialize correctly.");
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
bool CSystem::InitFileSystem()
|
||||
{
|
||||
@@ -1662,68 +1353,6 @@ bool CSystem::InitStreamEngine()
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
bool CSystem::InitFont(const SSystemInitParams& initParams)
|
||||
{
|
||||
LOADING_TIME_PROFILE_SECTION(GetISystem());
|
||||
|
||||
bool fontInited = false;
|
||||
AZ::CryFontCreationRequestBus::BroadcastResult(fontInited, &AZ::CryFontCreationRequests::CreateCryFont, m_env, initParams);
|
||||
if (!fontInited && !InitializeEngineModule(DLL_FONT, "EngineModule_CryFont", initParams))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_env.pCryFont)
|
||||
{
|
||||
AZ_Assert(false, "Font System did not initialize correctly; it could not be found in the system environment");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gEnv->IsDedicated())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!LoadFontInternal(m_pIFont, "default"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!LoadFontInternal(m_pIFontUi, "default-ui"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CSystem::Init3DEngine(const SSystemInitParams& initParams)
|
||||
{
|
||||
LOADING_TIME_PROFILE_SECTION(GetISystem());
|
||||
|
||||
if (!InitializeEngineModule(DLL_3DENGINE, "EngineModule_Cry3DEngine", initParams))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_env.p3DEngine)
|
||||
{
|
||||
AZ_Assert(false, "3D Engine did not initialize correctly; it could not be found in the system environment");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_env.p3DEngine->Init())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_pProcess = m_env.p3DEngine;
|
||||
m_pProcess->SetFlags(PROC_3DENGINE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CSystem::InitAudioSystem(const SSystemInitParams& initParams)
|
||||
{
|
||||
@@ -2785,42 +2414,6 @@ AZ_POP_DISABLE_WARNING
|
||||
}
|
||||
InlineInitializationProcessing("CSystem::Init InitLocalizations");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// RENDERER
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const bool loadLegacyRenderer = gEnv->IsEditor() ?
|
||||
LOAD_LEGACY_RENDERER_FOR_EDITOR :
|
||||
LOAD_LEGACY_RENDERER_FOR_LAUNCHER;
|
||||
if (loadLegacyRenderer && !startupParams.bSkipRenderer)
|
||||
{
|
||||
AZ_Assert(CryMemory::IsHeapValid(), "CryMemory must be valid before initializing renderer.");
|
||||
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "Renderer initialization");
|
||||
|
||||
if (!InitRenderer(m_hInst, m_hWnd, startupParams))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
AZ_Assert(CryMemory::IsHeapValid(), "CryMemory must be valid after initializing renderer.");
|
||||
if (m_env.pRenderer)
|
||||
{
|
||||
bool bMultiGPUEnabled = false;
|
||||
m_env.pRenderer->EF_Query(EFQ_MultiGPUEnabled, bMultiGPUEnabled);
|
||||
if (bMultiGPUEnabled)
|
||||
{
|
||||
LoadConfiguration("mgpu.cfg");
|
||||
}
|
||||
}
|
||||
|
||||
InlineInitializationProcessing("CSystem::Init InitRenderer");
|
||||
|
||||
if (m_env.pCryFont)
|
||||
{
|
||||
m_env.pCryFont->SetRendererProperties(m_env.pRenderer);
|
||||
}
|
||||
|
||||
AZ_Assert(m_env.pRenderer || startupParams.bSkipRenderer, "The renderer did not initialize correctly.");
|
||||
}
|
||||
|
||||
#if !defined(AZ_RELEASE_BUILD) && defined(AZ_PLATFORM_ANDROID)
|
||||
m_thermalInfoHandler = AZStd::make_unique<ThermalInfoAndroidHandler>();
|
||||
#endif
|
||||
@@ -2928,24 +2521,10 @@ AZ_POP_DISABLE_WARNING
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// FONT
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
if (!startupParams.bSkipFont)
|
||||
{
|
||||
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "Font initialization");
|
||||
if (!InitFont(startupParams))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
InlineInitializationProcessing("CSystem::Init InitFonts");
|
||||
|
||||
// The last update to the loading screen message was 'Initializing CryFont...'
|
||||
// Compiling the default system textures can be the lengthiest portion of
|
||||
// editor initialization, so it is useful to inform users that they are waiting on
|
||||
// the necessary default textures to compile, and that they are not waiting on CryFont.
|
||||
// the necessary default textures to compile.
|
||||
if (m_pUserCallback)
|
||||
{
|
||||
m_pUserCallback->OnInitProgress("First time asset processing - may take a minute...");
|
||||
@@ -3040,28 +2619,6 @@ AZ_POP_DISABLE_WARNING
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Init 3d engine
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
if (loadLegacyRenderer && !startupParams.bSkipRenderer && !startupParams.bShaderCacheGen)
|
||||
{
|
||||
AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "Initializing 3D Engine");
|
||||
INDENT_LOG_DURING_SCOPE();
|
||||
|
||||
if (!Init3DEngine(startupParams))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// try flush to keep renderer busy
|
||||
if (m_env.pRenderer)
|
||||
{
|
||||
m_env.pRenderer->TryFlush();
|
||||
}
|
||||
|
||||
InlineInitializationProcessing("CSystem::Init Init3DEngine");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// SERVICE NETWORK
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -4223,24 +3780,3 @@ void CSystem::SetAssertVisible(bool bAssertVisble)
|
||||
{
|
||||
m_bIsAsserting = bAssertVisble;
|
||||
}
|
||||
|
||||
bool CSystem::LoadFontInternal(IFFont*& font, const string& fontName)
|
||||
{
|
||||
font = m_env.pCryFont->NewFont(fontName);
|
||||
if (!font)
|
||||
{
|
||||
AZ_Assert(false, "Could not instantiate the default font.");
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
string szFontPath = "Fonts/" + fontName + ".font";
|
||||
|
||||
if (!font->Load(szFontPath.c_str()))
|
||||
{
|
||||
AZ_Error(AZ_TRACE_SYSTEM_WINDOW, false, "Could not load font: %s. Make sure the program is running from the correct working directory.", szFontPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+4
-9
@@ -10,8 +10,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Thumbnails/FolderThumbnail.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <QPixmap>
|
||||
@@ -50,8 +50,8 @@ namespace AzToolsFramework
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// FolderThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static constexpr const char* FolderIconPath = "Icons/AssetBrowser/Folder_16.svg";
|
||||
static constexpr const char* GemIconPath = "Icons/AssetBrowser/GemFolder_16.svg";
|
||||
static constexpr const char* FolderIconPath = "Assets/Editor/Icons/AssetBrowser/Folder_16.svg";
|
||||
static constexpr const char* GemIconPath = "Assets/Editor/Icons/AssetBrowser/GemFolder_16.svg";
|
||||
|
||||
FolderThumbnail::FolderThumbnail(SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
@@ -62,13 +62,8 @@ namespace AzToolsFramework
|
||||
auto folderKey = azrtti_cast<const FolderThumbnailKey*>(m_key.data());
|
||||
AZ_Assert(folderKey, "Incorrect key type, excpected FolderThumbnailKey");
|
||||
|
||||
const char* engineRoot = nullptr;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(engineRoot, &AzFramework::ApplicationRequests::GetEngineRoot);
|
||||
AZ_Assert(engineRoot, "Engine Root not initialized");
|
||||
const char* folderIcon = folderKey->IsGem() ? GemIconPath : FolderIconPath;
|
||||
AZStd::string absoluteIconPath;
|
||||
AZ::StringFunc::Path::Join(engineRoot, folderIcon, absoluteIconPath);
|
||||
|
||||
auto absoluteIconPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / folderIcon;
|
||||
m_pixmap.load(absoluteIconPath.c_str());
|
||||
m_state = m_pixmap.isNull() ? State::Failed : State::Ready;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzToolsFramework/Thumbnails/LoadingThumbnail.h>
|
||||
#include <AzFramework/Application/Application.h>
|
||||
|
||||
@@ -23,18 +23,14 @@ namespace AzToolsFramework
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// LoadingThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static const char* LoadingIconPath = "Icons/AssetBrowser/in_progress.gif";
|
||||
static constexpr const char* LoadingIconPath = "Assets/Editor/Icons/AssetBrowser/in_progress.gif";
|
||||
|
||||
LoadingThumbnail::LoadingThumbnail()
|
||||
: Thumbnail(MAKE_TKEY(ThumbnailKey))
|
||||
, m_angle(0)
|
||||
{
|
||||
const char* engineRoot = nullptr;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(engineRoot, &AzFramework::ApplicationRequests::GetEngineRoot);
|
||||
AZ_Assert(engineRoot, "Engine Root not initialized");
|
||||
AZStd::string iconPath;
|
||||
AZ::StringFunc::Path::Join(engineRoot, LoadingIconPath, iconPath);
|
||||
m_loadingMovie.setFileName(iconPath.c_str());
|
||||
auto absoluteIconPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / LoadingIconPath;
|
||||
m_loadingMovie.setFileName(absoluteIconPath.c_str());
|
||||
m_loadingMovie.setCacheMode(QMovie::CacheMode::CacheAll);
|
||||
m_loadingMovie.setScaledSize(QSize(LoadingThumbnailSize, LoadingThumbnailSize));
|
||||
m_loadingMovie.start();
|
||||
|
||||
@@ -10,18 +10,21 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzToolsFramework/Thumbnails/MissingThumbnail.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Thumbnailer
|
||||
{
|
||||
static const char* MISSING_ICON_PATH = "Icons/AssetBrowser/Default_16.svg";
|
||||
static constexpr const char* MissingIconPath = "Assets/Editor/Icons/AssetBrowser/Default_16.svg";
|
||||
|
||||
MissingThumbnail::MissingThumbnail()
|
||||
: Thumbnail(MAKE_TKEY(ThumbnailKey))
|
||||
{
|
||||
m_pixmap.load(MISSING_ICON_PATH);
|
||||
auto absoluteIconPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / MissingIconPath;
|
||||
m_pixmap.load(absoluteIconPath.c_str());
|
||||
m_state = m_pixmap.isNull() ? State::Failed : State::Ready;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,15 +20,6 @@
|
||||
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
#define DECLARE_CRYREGISTER_SINGLETON_CLASS(implclassname) \
|
||||
void* Get##implclassname##Factory();
|
||||
|
||||
DECLARE_CRYREGISTER_SINGLETON_CLASS(CEngineModule_Cry3DEngine)
|
||||
DECLARE_CRYREGISTER_SINGLETON_CLASS(CEngineModule_CryFont)
|
||||
DECLARE_CRYREGISTER_SINGLETON_CLASS(CEngineModule_CryRenderer)
|
||||
|
||||
#undef DECLARE_CRYREGISTER_SINGLETON_CLASS
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class Module;
|
||||
@@ -39,14 +30,6 @@ ${extern_module_declarations}
|
||||
extern "C" void CreateStaticModules(AZStd::vector<AZ::Module*>& modulesOut)
|
||||
{
|
||||
${module_invocations}
|
||||
// Call methods to avoid symbol striping
|
||||
#define NON_STRIPPING_CALL(Module) \
|
||||
AZ_UNUSED(Get##Module##Factory())
|
||||
|
||||
NON_STRIPPING_CALL(CEngineModule_Cry3DEngine);
|
||||
NON_STRIPPING_CALL(CEngineModule_CryFont);
|
||||
NON_STRIPPING_CALL(CEngineModule_CryRenderer);
|
||||
#undef NON_STRIPPING_CALL
|
||||
}
|
||||
|
||||
#endif // AZ_MONOLITHIC_BUILD
|
||||
|
||||
@@ -66,7 +66,6 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC
|
||||
set(game_build_dependencies
|
||||
${game_gem_dependencies}
|
||||
Legacy::CrySystem
|
||||
Legacy::CryFont
|
||||
)
|
||||
|
||||
if(PAL_TRAIT_BUILD_SERVER_SUPPORTED)
|
||||
@@ -95,7 +94,6 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC
|
||||
set(server_build_dependencies
|
||||
${game_gem_dependencies}
|
||||
Legacy::CrySystem
|
||||
Legacy::CryFont
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -103,7 +101,6 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC
|
||||
|
||||
set(game_runtime_dependencies
|
||||
Legacy::CrySystem
|
||||
Legacy::CryFont
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
@@ -36,7 +36,6 @@ void RegisterReflectedVarHandlers()
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LocalStringPropertyHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LightAnimationPropertyHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew UserPopupWidgetHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LensFlareHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew ColorCurveHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew FloatCurveHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew MotionPropertyWidgetHandler());
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
// Editor
|
||||
#include "GenericSelectItemDialog.h"
|
||||
#include "QtViewPaneManager.h"
|
||||
#include "LensFlareEditor/LensFlareEditor.h"
|
||||
|
||||
|
||||
UserPropertyEditor::UserPropertyEditor(QWidget *pParent /*= nullptr*/)
|
||||
@@ -147,79 +146,6 @@ bool UserPopupWidgetHandler::ReadValuesIntoGUI(size_t index, UserPropertyEditor*
|
||||
|
||||
#include <Controls/ReflectedPropertyControl/moc_PropertyMiscCtrl.cpp>
|
||||
|
||||
LensFlarePropertyWidget::LensFlarePropertyWidget(QWidget *pParent /*= nullptr*/)
|
||||
:QWidget(pParent)
|
||||
{
|
||||
m_valueEdit = new QLineEdit;
|
||||
|
||||
QToolButton *mainButton = new QToolButton;
|
||||
mainButton->setText("D");
|
||||
connect(mainButton, &QToolButton::clicked, this, &LensFlarePropertyWidget::OnEditClicked);
|
||||
connect(m_valueEdit, &QLineEdit::editingFinished, m_valueEdit, [this] () {emit ValueChanged(m_valueEdit->text());});
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout(this);
|
||||
mainLayout->addWidget(m_valueEdit, 1);
|
||||
mainLayout->addWidget(mainButton);
|
||||
mainLayout->setContentsMargins(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
void LensFlarePropertyWidget::SetValue(const QString &value)
|
||||
{
|
||||
m_valueEdit->setText(value);
|
||||
}
|
||||
|
||||
QString LensFlarePropertyWidget::GetValue() const
|
||||
{
|
||||
return m_valueEdit->text();
|
||||
}
|
||||
|
||||
void LensFlarePropertyWidget::OnEditClicked()
|
||||
{
|
||||
const QtViewPane *lensFlarePane = GetIEditor()->OpenView(CLensFlareEditor::s_pLensFlareEditorClassName);
|
||||
if (!lensFlarePane)
|
||||
return;
|
||||
|
||||
CLensFlareEditor *editor = FindViewPane<CLensFlareEditor>(QtUtil::ToQString(CLensFlareEditor::s_pLensFlareEditorClassName));
|
||||
if (editor)
|
||||
QTimer::singleShot(0, editor, SLOT(OnUpdateTreeCtrl()));
|
||||
}
|
||||
|
||||
QWidget* LensFlareHandler::CreateGUI(QWidget *pParent)
|
||||
{
|
||||
LensFlarePropertyWidget* newCtrl = aznew LensFlarePropertyWidget(pParent);
|
||||
connect(newCtrl, &LensFlarePropertyWidget::ValueChanged, newCtrl, [newCtrl]()
|
||||
{
|
||||
EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, newCtrl);
|
||||
});
|
||||
|
||||
return newCtrl;
|
||||
}
|
||||
|
||||
void LensFlareHandler::ConsumeAttribute(LensFlarePropertyWidget* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName)
|
||||
{
|
||||
Q_UNUSED(GUI); Q_UNUSED(attrib); Q_UNUSED(attrValue); Q_UNUSED(debugName);
|
||||
}
|
||||
|
||||
void LensFlareHandler::WriteGUIValuesIntoProperty(size_t index, LensFlarePropertyWidget* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(node);
|
||||
CReflectedVarGenericProperty val = instance;
|
||||
val.m_value = GUI->GetValue().toUtf8().data();
|
||||
instance = static_cast<property_t>(val);
|
||||
}
|
||||
|
||||
bool LensFlareHandler::ReadValuesIntoGUI(size_t index, LensFlarePropertyWidget* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(node);
|
||||
CReflectedVarGenericProperty val = instance;
|
||||
GUI->SetValue(val.m_value.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QWidget* FloatCurveHandler::CreateGUI(QWidget *pParent)
|
||||
{
|
||||
CSplineCtrl *cSpline = new CSplineCtrl(pParent);
|
||||
|
||||
@@ -70,39 +70,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class LensFlarePropertyWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(LensFlarePropertyWidget, AZ::SystemAllocator, 0);
|
||||
LensFlarePropertyWidget(QWidget *pParent = nullptr);
|
||||
|
||||
void SetValue(const QString &value);
|
||||
QString GetValue() const;
|
||||
|
||||
void OnEditClicked();
|
||||
|
||||
signals:
|
||||
void ValueChanged(const QString &value);
|
||||
|
||||
private:
|
||||
QLineEdit *m_valueEdit;
|
||||
};
|
||||
|
||||
class LensFlareHandler : public QObject, public AzToolsFramework::PropertyHandler < CReflectedVarGenericProperty, LensFlarePropertyWidget>
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(LensFlareHandler, AZ::SystemAllocator, 0);
|
||||
bool IsDefaultHandler() const override { return false; }
|
||||
QWidget* CreateGUI(QWidget *pParent) override;
|
||||
|
||||
AZ::u32 GetHandlerName(void) const override { return AZ_CRC("ePropertyFlare", 0x5ce803df); }
|
||||
void ConsumeAttribute(LensFlarePropertyWidget* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
|
||||
void WriteGUIValuesIntoProperty(size_t index, LensFlarePropertyWidget* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
bool ReadValuesIntoGUI(size_t index, LensFlarePropertyWidget* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
};
|
||||
|
||||
class FloatCurveHandler : public QObject, public AzToolsFramework::PropertyHandler < CReflectedVarSpline, CSplineCtrl>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -279,7 +279,6 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
|
||||
case ePropertyLocalString:
|
||||
case ePropertyLightAnimation:
|
||||
case ePropertyParticleName:
|
||||
case ePropertyFlare:
|
||||
m_reflectedVarAdapter = new ReflectedVarGenericPropertyAdapter(desc.m_type);
|
||||
break;
|
||||
case ePropertyTexture:
|
||||
|
||||
@@ -308,8 +308,6 @@ AZ::u32 CReflectedVarGenericProperty::handler()
|
||||
return AZ_CRC("ePropertyLightAnimation", 0x277097da);
|
||||
case ePropertyParticleName:
|
||||
return AZ_CRC("ePropertyParticleName", 0xf44c7133);
|
||||
case ePropertyFlare:
|
||||
return AZ_CRC("ePropertyFlare", 0x5ce803df);
|
||||
default:
|
||||
AZ_Assert(false, "No property handlers defined for the property type");
|
||||
return AZ_CRC("Default", 0xe35e00df);
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
#include "ActionManager.h"
|
||||
#include "Include/IObjectManager.h"
|
||||
#include "Material/MaterialManager.h"
|
||||
#include "LensFlareEditor/LensFlareManager.h"
|
||||
#include "ErrorReportDialog.h"
|
||||
#include "SurfaceTypeValidator.h"
|
||||
#include "ShaderCache.h"
|
||||
@@ -360,8 +359,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
|
||||
SerializeMissions(arrXmlAr, currentMissionName, false);
|
||||
//! Serialize material manager.
|
||||
GetIEditor()->GetMaterialManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
|
||||
//! Serialize LensFlare manager.
|
||||
GetIEditor()->GetLensFlareManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
|
||||
|
||||
SerializeShaderCache((*arrXmlAr[DMAS_GENERAL_NAMED_DATA]));
|
||||
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
|
||||
@@ -524,14 +521,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
|
||||
GetIEditor()->GetMaterialManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Load LensFlares.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
CAutoLogTime logtime("Load Flares");
|
||||
GetIEditor()->GetLensFlareManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Load View Settings
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,250 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#pragma once
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Crytek Engine Source File.
|
||||
// Copyright (C), Crytek Studios, 2011.
|
||||
// -------------------------------------------------------------------------
|
||||
// File name: DatabaseFrameWnd.h
|
||||
// Created: 10/Dec/2012 by Jaesik.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef CRYINCLUDE_EDITOR_DATABASEFRAMEWND_H
|
||||
#define CRYINCLUDE_EDITOR_DATABASEFRAMEWND_H
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
|
||||
#include <AzQtComponents/Components/DockMainWindow.h>
|
||||
#include "Undo/IUndoManagerListener.h"
|
||||
#include "BaseLibrary.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAbstractListModel>
|
||||
#include <QScopedPointer>
|
||||
#endif
|
||||
|
||||
class QComboBox;
|
||||
class QTreeView;
|
||||
class QMimeData;
|
||||
|
||||
class CBaseLibraryItem;
|
||||
class CBaseLibraryManager;
|
||||
|
||||
class LibraryListModel;
|
||||
class LibraryItemTreeModel;
|
||||
|
||||
namespace Ui {
|
||||
class DatabaseFrameWnd;
|
||||
}
|
||||
|
||||
class CDatabaseFrameWnd
|
||||
: public AzQtComponents::DockMainWindow
|
||||
, public IEditorNotifyListener
|
||||
, public IUndoManagerListener
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CDatabaseFrameWnd(CBaseLibraryManager* pItemManager, QWidget* pParent = nullptr);
|
||||
virtual ~CDatabaseFrameWnd();
|
||||
|
||||
enum SortRecursionType
|
||||
{
|
||||
SORT_RECURSION_NONE = 1,
|
||||
SORT_RECURSION_ITEM = 2,
|
||||
SORT_RECURSION_FULL = 9999
|
||||
};
|
||||
|
||||
virtual void ReloadLibs();
|
||||
virtual void ReloadItems();
|
||||
virtual void SelectLibrary(const QString& library, bool bForceSelect = false);
|
||||
virtual void SelectLibrary(CBaseLibrary* pItem, bool bForceSelect = false);
|
||||
virtual void SelectItem(CBaseLibraryItem* item, bool bForceReload = false);
|
||||
|
||||
virtual CBaseLibrary* FindLibrary(const QString& libraryName);
|
||||
virtual CBaseLibrary* NewLibrary(const QString& libraryName);
|
||||
virtual void DeleteLibrary(CBaseLibrary* pLibrary);
|
||||
virtual void DeleteItem(CBaseLibraryItem* pItem);
|
||||
|
||||
virtual void ReleasePreviewControl(){}
|
||||
|
||||
virtual bool SetItemName(CBaseLibraryItem* item, const QString& groupName, const QString& itemName);
|
||||
|
||||
void DoesItemExist(const QString& itemName, bool& bOutExist) const;
|
||||
void DoesGroupExist(const QString& groupName, bool& bOutExist) const;
|
||||
|
||||
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
|
||||
|
||||
void SignalNumUndoRedo(const unsigned int& numUndo, const unsigned int& numRedo) override;
|
||||
|
||||
QString GetSelectedLibraryName() const;
|
||||
|
||||
virtual const char* GetClassName() = 0;
|
||||
|
||||
protected:
|
||||
int GetComboBoxIndex(CBaseLibrary* pLibrary);
|
||||
|
||||
virtual void OnInitDialog() = 0;
|
||||
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
void OnUndo();
|
||||
void OnRedo();
|
||||
|
||||
virtual void OnAddLibrary();
|
||||
virtual void OnRemoveLibrary();
|
||||
virtual void OnAddItem();
|
||||
virtual void OnRemoveItem();
|
||||
virtual void OnRenameItem();
|
||||
virtual void OnChangedLibrary();
|
||||
virtual void OnExportLibrary();
|
||||
virtual void OnSave();
|
||||
virtual void OnReloadLib();
|
||||
virtual void OnLoadLibrary();
|
||||
|
||||
void OnSelChangedItemTree(const QModelIndex& index);
|
||||
bool eventFilter(QObject* watched, QEvent* event);
|
||||
|
||||
virtual void OnCopy() = 0;
|
||||
virtual void OnPaste() = 0;
|
||||
virtual void OnCut();
|
||||
virtual void OnClone();
|
||||
|
||||
void InitTreeCtrl();
|
||||
|
||||
virtual AssetSelectionModel GetAssetSelectionModel() const = 0;
|
||||
|
||||
void LoadLibrary();
|
||||
|
||||
QString MakeValidName(const QString& candidateName, AZStd::function<void(const QString&, bool&)> cb) const;
|
||||
|
||||
virtual QTreeView* GetTreeCtrl() = 0;
|
||||
virtual const QTreeView* GetTreeCtrl() const = 0;
|
||||
|
||||
private:
|
||||
LibraryListModel* m_pLibraryListModel;
|
||||
QComboBox* m_pLibraryListComboBox;
|
||||
|
||||
bool m_bLibsLoaded;
|
||||
|
||||
protected:
|
||||
LibraryItemTreeModel* m_pLibraryItemTreeModel;
|
||||
|
||||
//! Selected library.
|
||||
_smart_ptr<CBaseLibrary> m_pLibrary;
|
||||
|
||||
//! Last selected Item. (kept here for compatibility reasons)
|
||||
// See comments on m_cpoSelectedLibraryItems for more details.
|
||||
_smart_ptr<CBaseLibraryItem> m_pCurrentItem;
|
||||
|
||||
// A set containing all the currently selected items
|
||||
// (it's disabled for MOST, but not ALL cases).
|
||||
// This should be the new standard way of storing selections as
|
||||
// opposed to the former mean, it allows us to store multiple selections.
|
||||
// The migration to this new style should be done according to the needs
|
||||
// for multiple selection.
|
||||
std::set<CBaseLibraryItem*> m_cpoSelectedLibraryItems;
|
||||
|
||||
//! Pointer to item manager.
|
||||
CBaseLibraryManager* m_pItemManager;
|
||||
SortRecursionType m_sortRecursionType;
|
||||
QString m_selectedGroup;
|
||||
|
||||
QScopedPointer<Ui::DatabaseFrameWnd> ui;
|
||||
|
||||
bool m_initialized;
|
||||
};
|
||||
|
||||
class LibraryListModel
|
||||
: public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LibraryListModel(CBaseLibraryManager* itemManager, QObject* pParent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex& parent = {}) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
void Reload();
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
void LibraryModified(bool bModified);
|
||||
|
||||
CBaseLibraryManager* m_pItemManager;
|
||||
};
|
||||
|
||||
class LibraryItemTreeModel
|
||||
: public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
using Group = std::pair<QString, std::vector<CBaseLibraryItem*> >;
|
||||
|
||||
public:
|
||||
LibraryItemTreeModel(CDatabaseFrameWnd* pParent);
|
||||
|
||||
QModelIndex parent(const QModelIndex& index) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex& parent = {}) const override;
|
||||
QModelIndex index(CBaseLibraryItem* pItem) const;
|
||||
|
||||
int rowCount(const QModelIndex& parent) const override;
|
||||
int columnCount(const QModelIndex& parent) const override;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
||||
|
||||
bool removeRows(int row, int count, const QModelIndex& parent = {}) override;
|
||||
|
||||
QStringList mimeTypes() const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
|
||||
QMimeData* mimeData(const QModelIndexList& indexes) const override;
|
||||
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
|
||||
void Clear();
|
||||
|
||||
void Reload(CBaseLibrary* library);
|
||||
|
||||
void Add(CBaseLibraryItem* item);
|
||||
bool Remove(CBaseLibraryItem* item);
|
||||
|
||||
void Rename(CBaseLibraryItem* item, const QString& groupName, const QString& shortName);
|
||||
|
||||
std::vector<CBaseLibraryItem*> ChildItems(const QModelIndex& index) const;
|
||||
|
||||
QString GetFullName(const QModelIndex& index) const;
|
||||
|
||||
QModelIndex FindLibraryItemByFullName(const QString& fullName) const;
|
||||
bool DoesGroupExist(const QString& groupName) const;
|
||||
|
||||
signals:
|
||||
void itemRenamed(CBaseLibraryItem* item, const QString& prevFullName);
|
||||
|
||||
protected:
|
||||
void RenameItem(CBaseLibraryItem* item, const QString& fullName);
|
||||
QString MakeValidName(const Group& group, const QString& baseName) const;
|
||||
bool MoveItem(CBaseLibraryItem* item, const QModelIndex& parent);
|
||||
|
||||
CDatabaseFrameWnd* m_dialog;
|
||||
|
||||
std::map<QString, std::shared_ptr<Group> > m_groups;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(CBaseLibrary*)
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_DATABASEFRAMEWND_H
|
||||
@@ -1,35 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/DatabaseFrameWnd">
|
||||
<file alias="db_library_bar_00.png">res/db_library_bar_00.png</file>
|
||||
<file alias="db_library_bar_01.png">res/db_library_bar_01.png</file>
|
||||
<file alias="db_library_bar_02.png">res/db_library_bar_02.png</file>
|
||||
<file alias="db_library_bar_03.png">res/db_library_bar_03.png</file>
|
||||
<file alias="db_library_bar_04.png">res/db_library_bar_04.png</file>
|
||||
<file alias="db_library_bar_05.png">res/db_library_bar_05.png</file>
|
||||
<file alias="db_standart_00.png">res/db_standart_00.png</file>
|
||||
<file alias="db_standart_01.png">res/db_standart_01.png</file>
|
||||
<file alias="db_standart_02.png">res/db_standart_02.png</file>
|
||||
<file alias="db_standart_03.png">res/db_standart_03.png</file>
|
||||
<file alias="db_library_item_bar_00.png">res/db_library_item_bar_00.png</file>
|
||||
<file alias="db_library_item_bar_01.png">res/db_library_item_bar_01.png</file>
|
||||
<file alias="db_library_item_bar_02.png">res/db_library_item_bar_02.png</file>
|
||||
<file alias="db_library_item_bar_03.png">res/db_library_item_bar_03.png</file>
|
||||
<file alias="db_library_item_bar_04.png">res/db_library_item_bar_04.png</file>
|
||||
<file alias="db_library_item_bar_05.png">res/db_library_item_bar_05.png</file>
|
||||
<file alias="db_library_open.svg">res/db_library_open.svg</file>
|
||||
<file alias="db_library_save.svg">res/db_library_save.svg</file>
|
||||
<file alias="db_library_add.svg">res/db_library_add.svg</file>
|
||||
<file alias="db_library_delete.svg">res/db_library_delete.svg</file>
|
||||
<file alias="db_library_refresh.svg">res/db_library_refresh.svg</file>
|
||||
<file alias="db_library_undo.svg">res/db_library_undo.svg</file>
|
||||
<file alias="db_library_redo.svg">res/db_library_redo.svg</file>
|
||||
<file alias="db_library_copy.svg">res/db_library_copy.svg</file>
|
||||
<file alias="db_library_paste.svg">res/db_library_paste.svg</file>
|
||||
<file alias="db_library_additem.svg">res/db_library_additem.svg</file>
|
||||
<file alias="db_library_cloneitem.svg">res/db_library_cloneitem.svg</file>
|
||||
<file alias="db_library_removeitem.svg">res/db_library_removeitem.svg</file>
|
||||
<file alias="db_library_assignitem.svg">res/db_library_assignitem.svg</file>
|
||||
<file alias="db_library_getproperties.svg">res/db_library_getproperties.svg</file>
|
||||
<file alias="db_library_reload.svg">res/db_library_reload.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1,279 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DatabaseFrameWnd</class>
|
||||
<widget class="QMainWindow" name="DatabaseFrameWnd">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>633</width>
|
||||
<height>42</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QToolBar" name="m_toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>Lens Flare Toolbar</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="floatable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionDBLoadLib"/>
|
||||
<addaction name="actionDBSave"/>
|
||||
<addaction name="actionDBAddLib"/>
|
||||
<addaction name="actionDBDelLib"/>
|
||||
<addaction name="actionDBReloadLib"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="m_toolBar2">
|
||||
<property name="windowTitle">
|
||||
<string>StandartToolBar</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="floatable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionUndo"/>
|
||||
<addaction name="actionRedo"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionDBCopy"/>
|
||||
<addaction name="actionDBPaste"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="m_toolBar3">
|
||||
<property name="windowTitle">
|
||||
<string>ItemToolBar</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="floatable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionDBAdd"/>
|
||||
<addaction name="actionDBClone"/>
|
||||
<addaction name="actionDBRemove"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionDBAssignToSelection"/>
|
||||
<addaction name="actionDBGetFromSelection"/>
|
||||
<addaction name="actionDBReload"/>
|
||||
</widget>
|
||||
<action name="actionDBLoadLib">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_open.svg</normaloff>:/DatabaseFrameWnd/db_library_open.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load Library</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Load Library</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBSave">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_save.svg</normaloff>:/DatabaseFrameWnd/db_library_save.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save Modified Libraries</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save Modified Libraries</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBAddLib">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_add.svg</normaloff>:/DatabaseFrameWnd/db_library_add.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Library</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add Library</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBDelLib">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_delete.svg</normaloff>:/DatabaseFrameWnd/db_library_delete.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove Library</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove Library</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBReloadLib">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_refresh.svg</normaloff>:/DatabaseFrameWnd/db_library_refresh.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reload Library</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reload Library</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUndo">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_undo.svg</normaloff>:/DatabaseFrameWnd/db_library_undo.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Undo last operation</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Undo</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRedo">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_redo.svg</normaloff>:/DatabaseFrameWnd/db_library_redo.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Redo last undo operation</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Redo</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBCopy">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_copy.svg</normaloff>:/DatabaseFrameWnd/db_library_copy.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copy Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Copy Item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBPaste">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_paste.svg</normaloff>:/DatabaseFrameWnd/db_library_paste.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Paste Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Paste Item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBAdd">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_additem.svg</normaloff>:/DatabaseFrameWnd/db_library_additem.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add New Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add New Item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBClone">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_cloneitem.svg</normaloff>:/DatabaseFrameWnd/db_library_cloneitem.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clone Library Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Clone Library Item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBRemove">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_removeitem.svg</normaloff>:/DatabaseFrameWnd/db_library_removeitem.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove Item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBAssignToSelection">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_assignitem.svg</normaloff>:/DatabaseFrameWnd/db_library_assignitem.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Assign Item to Selected Objects</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Assign Item to Selected Objects</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBGetFromSelection">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_getproperties.svg</normaloff>:/DatabaseFrameWnd/db_library_getproperties.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Get Properties From Selection</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Get Properties From Selection</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBReload">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_reload.svg</normaloff>:/DatabaseFrameWnd/db_library_reload.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reload Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reload Item</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -34,9 +34,6 @@
|
||||
#include "Objects/ObjectManager.h"
|
||||
|
||||
#include "Objects/EntityObject.h"
|
||||
#include "LensFlareEditor/LensFlareManager.h"
|
||||
#include "LensFlareEditor/LensFlareLibrary.h"
|
||||
#include "LensFlareEditor/LensFlareItem.h"
|
||||
|
||||
#include <AzFramework/Terrain/TerrainDataRequestBus.h>
|
||||
|
||||
@@ -210,7 +207,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
|
||||
|
||||
ExportLevelInfo(sLevelPath);
|
||||
|
||||
ExportLevelLensFlares(sLevelPath);
|
||||
ExportLevelResourceList(sLevelPath);
|
||||
ExportLevelUsedResourceList(sLevelPath);
|
||||
ExportLevelShaderCache(sLevelPath);
|
||||
@@ -554,67 +550,6 @@ void CGameExporter::ExportMaterials(XmlNodeRef& levelDataNode, const QString& pa
|
||||
m_numExportedMaterials = numMtls;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameExporter::ExportLevelLensFlares(const QString& path)
|
||||
{
|
||||
GetIEditor()->SetStatusText(QObject::tr("Exporting Lens Flares..."));
|
||||
std::vector<CBaseObject*> objects;
|
||||
GetIEditor()->GetObjectManager()->FindObjectsOfType(&CEntityObject::staticMetaObject, objects);
|
||||
std::set<QString> flareNameSet;
|
||||
for (int i = 0, iObjectSize(objects.size()); i < iObjectSize; ++i)
|
||||
{
|
||||
CEntityObject* pEntity = (CEntityObject*)objects[i];
|
||||
if (!pEntity->IsLight())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QString flareName = pEntity->GetEntityPropertyString(CEntityObject::s_LensFlarePropertyName);
|
||||
if (flareName.isEmpty() || flareName == "@root")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
flareNameSet.insert(flareName);
|
||||
}
|
||||
|
||||
XmlNodeRef pRootNode = GetIEditor()->GetSystem()->CreateXmlNode("LensFlareList");
|
||||
pRootNode->setAttr("Version", FLARE_EXPORT_FILE_VERSION);
|
||||
|
||||
CLensFlareManager* pLensManager = GetIEditor()->GetLensFlareManager();
|
||||
|
||||
if (CLensFlareLibrary* pLevelLib = (CLensFlareLibrary*)pLensManager->GetLevelLibrary())
|
||||
{
|
||||
for (int i = 0; i < pLevelLib->GetItemCount(); i++)
|
||||
{
|
||||
CLensFlareItem* pItem = (CLensFlareItem*)pLevelLib->GetItem(i);
|
||||
|
||||
if (flareNameSet.find(pItem->GetFullName()) == flareNameSet.end())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CBaseLibraryItem::SerializeContext ctx(pItem->CreateXmlData(), false);
|
||||
pRootNode->addChild(ctx.node);
|
||||
pItem->Serialize(ctx);
|
||||
flareNameSet.erase(pItem->GetFullName());
|
||||
}
|
||||
}
|
||||
|
||||
std::set<QString>::iterator iFlareNameSet = flareNameSet.begin();
|
||||
for (; iFlareNameSet != flareNameSet.end(); ++iFlareNameSet)
|
||||
{
|
||||
QString flareName = *iFlareNameSet;
|
||||
XmlNodeRef pFlareNode = GetIEditor()->GetSystem()->CreateXmlNode("LensFlare");
|
||||
pFlareNode->setAttr("name", flareName.toUtf8().data());
|
||||
pRootNode->addChild(pFlareNode);
|
||||
}
|
||||
|
||||
CCryMemFile lensFlareNames;
|
||||
lensFlareNames.Write(pRootNode->getXMLData()->GetString(), pRootNode->getXMLData()->GetStringLength());
|
||||
|
||||
QString exportPathName = path + FLARE_EXPORT_FILE;
|
||||
m_levelPak.m_pakFile.UpdateFile(exportPathName.toUtf8().data(), lensFlareNames);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameExporter::ExportLevelResourceList(const QString& path)
|
||||
{
|
||||
|
||||
@@ -95,7 +95,6 @@ private:
|
||||
void ExportOcclusionMesh(const char* pszGamePath);
|
||||
void ExportMapInfo(XmlNodeRef& node);
|
||||
|
||||
void ExportLevelLensFlares(const QString& path);
|
||||
void ExportLevelResourceList(const QString& path);
|
||||
void ExportLevelUsedResourceList(const QString& path);
|
||||
void ExportLevelShaderCache(const QString& path);
|
||||
|
||||
@@ -50,7 +50,6 @@ class CMaterialManager;
|
||||
class CMusicManager;
|
||||
class CMaterail;
|
||||
struct IEditorParticleManager;
|
||||
class CLensFlareManager;
|
||||
class CEAXPresetManager;
|
||||
class CErrorReport;
|
||||
class CBaseLibraryItem;
|
||||
@@ -555,8 +554,6 @@ struct IEditor
|
||||
virtual IEditorPanelUtils* GetEditorPanelUtils() = 0;
|
||||
//! Get Music Manager.
|
||||
virtual CMusicManager* GetMusicManager() = 0;
|
||||
//! Get Lens Flare Manager.
|
||||
virtual CLensFlareManager* GetLensFlareManager() = 0;
|
||||
virtual float GetTerrainElevation(float x, float y) = 0;
|
||||
virtual Editor::EditorQtApplication* GetEditorQtApplication() = 0;
|
||||
virtual const QColor& GetColorByName(const QString& name) = 0;
|
||||
|
||||
@@ -60,7 +60,6 @@ AZ_POP_DISABLE_WARNING
|
||||
#include "ToolBox.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Alembic/AlembicCompiler.h"
|
||||
#include "LensFlareEditor/LensFlareManager.h"
|
||||
#include "UIEnumsDatabase.h"
|
||||
#include "Util/Ruler.h"
|
||||
#include "RenderHelpers/AxisHelper.h"
|
||||
@@ -170,7 +169,6 @@ CEditorImpl::CEditorImpl()
|
||||
, m_pToolBoxManager(nullptr)
|
||||
, m_pMaterialManager(nullptr)
|
||||
, m_pMusicManager(nullptr)
|
||||
, m_pLensFlareManager(nullptr)
|
||||
, m_pErrorReport(nullptr)
|
||||
, m_pLasLoadedLevelErrorReport(nullptr)
|
||||
, m_pErrorsDlg(nullptr)
|
||||
@@ -230,7 +228,6 @@ CEditorImpl::CEditorImpl()
|
||||
m_pAnimationContext = new CAnimationContext;
|
||||
|
||||
m_pImageUtil = new CImageUtil_impl();
|
||||
m_pLensFlareManager = new CLensFlareManager;
|
||||
m_pResourceSelectorHost.reset(CreateResourceSelectorHost());
|
||||
m_pRuler = new CRuler;
|
||||
m_selectedRegion.min = Vec3(0, 0, 0);
|
||||
|
||||
@@ -42,7 +42,6 @@ class CUndoManager;
|
||||
class CGameEngine;
|
||||
class CExportManager;
|
||||
class CErrorsDlg;
|
||||
class CLensFlareManager;
|
||||
class CIconManager;
|
||||
class CBackgroundTaskManager;
|
||||
class CTrackViewSequenceManager;
|
||||
@@ -183,7 +182,6 @@ public:
|
||||
IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType);
|
||||
CMaterialManager* GetMaterialManager() { return m_pMaterialManager; }
|
||||
CMusicManager* GetMusicManager() { return m_pMusicManager; };
|
||||
CLensFlareManager* GetLensFlareManager() { return m_pLensFlareManager; };
|
||||
|
||||
IBackgroundTaskManager* GetBackgroundTaskManager() override;
|
||||
IBackgroundScheduleManager* GetBackgroundScheduleManager() override;
|
||||
@@ -384,7 +382,6 @@ protected:
|
||||
CMaterialManager* m_pMaterialManager;
|
||||
CAlembicCompiler* m_pAlembicCompiler;
|
||||
CMusicManager* m_pMusicManager;
|
||||
CLensFlareManager* m_pLensFlareManager;
|
||||
CErrorReport* m_pErrorReport;
|
||||
//! Contains the error reports for the last loaded level.
|
||||
CErrorReport* m_pLasLoadedLevelErrorReport;
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_ILENSFLARELISTENER_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_ILENSFLARELISTENER_H
|
||||
#pragma once
|
||||
|
||||
class CLensFlareItem;
|
||||
class CLensFlareElement;
|
||||
|
||||
class ILensFlareChangeItemListener
|
||||
{
|
||||
public:
|
||||
virtual void OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem) = 0;
|
||||
virtual void OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem) = 0;
|
||||
};
|
||||
|
||||
class ILensFlareChangeElementListener
|
||||
{
|
||||
public:
|
||||
virtual void OnLensFlareChangeElement(CLensFlareElement* pLensFlareElement) = 0;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_ILENSFLARELISTENER_H
|
||||
@@ -1,326 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LensFlareAtomicList.h"
|
||||
|
||||
// Qt
|
||||
#include <QScrollBar>
|
||||
#include <QMimeData>
|
||||
|
||||
// Editor
|
||||
#include "LensFlareUtil.h"
|
||||
#include "Util/Image.h"
|
||||
#include "Util/ImageUtil.h"
|
||||
|
||||
|
||||
struct QLensFlareAtomicListModel::Item
|
||||
{
|
||||
QString text;
|
||||
QSize size;
|
||||
QPixmap pixmap;
|
||||
EFlareType flareType;
|
||||
};
|
||||
|
||||
CLensFlareAtomicList::CLensFlareAtomicList(QWidget* parent)
|
||||
: CImageListCtrl(parent)
|
||||
, m_model(new QLensFlareAtomicListModel(this))
|
||||
{
|
||||
setDragEnabled(true);
|
||||
setDragDropMode(DragOnly);
|
||||
setModel(m_model.data());
|
||||
}
|
||||
|
||||
CLensFlareAtomicList::~CLensFlareAtomicList()
|
||||
{
|
||||
}
|
||||
|
||||
QModelIndex QLensFlareAtomicListModel::InsertItem(const FlareInfo& flareInfo)
|
||||
{
|
||||
Item* pPreviewItem = new Item;
|
||||
|
||||
if (flareInfo.imagename)
|
||||
{
|
||||
CImageEx* pImage = new CImageEx();
|
||||
if (CImageUtil::LoadImage(flareInfo.imagename, *pImage))
|
||||
{
|
||||
pImage->SwapRedAndBlue();
|
||||
pPreviewItem->size = QSize(pImage->GetWidth(), pImage->GetHeight());
|
||||
QImage img(reinterpret_cast<const uchar*>(pImage->GetData()), pImage->GetWidth(), pImage->GetHeight(), QImage::Format_RGB32);
|
||||
pPreviewItem->pixmap = QPixmap::fromImage(img.copy());
|
||||
}
|
||||
|
||||
delete pImage;
|
||||
}
|
||||
|
||||
if (pPreviewItem->pixmap.isNull())
|
||||
{
|
||||
pPreviewItem->pixmap = QPixmap(":/water.png");
|
||||
pPreviewItem->size = QSize(64, 64);
|
||||
}
|
||||
|
||||
pPreviewItem->text = flareInfo.name;
|
||||
pPreviewItem->flareType = flareInfo.type;
|
||||
|
||||
const int row = m_items.count();
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
m_items.append(pPreviewItem);
|
||||
endInsertRows();
|
||||
|
||||
return index(row, 0);
|
||||
}
|
||||
|
||||
void QLensFlareAtomicListModel::Populate()
|
||||
{
|
||||
Clear();
|
||||
const FlareInfoArray::Props array = FlareInfoArray::Get();
|
||||
for (size_t i = 0; i < array.size; ++i)
|
||||
{
|
||||
const FlareInfo& flareInfo(array.p[i]);
|
||||
if (LensFlareUtil::IsElement(flareInfo.type))
|
||||
{
|
||||
InsertItem(flareInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLensFlareAtomicList::FillAtomicItems()
|
||||
{
|
||||
if (m_model)
|
||||
{
|
||||
m_model->Populate();
|
||||
}
|
||||
}
|
||||
|
||||
void CLensFlareAtomicList::updateGeometries()
|
||||
{
|
||||
ClearItemGeometries();
|
||||
|
||||
if (!model())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int rowCount = model()->rowCount();
|
||||
|
||||
const int nPageHorz = viewport()->width();
|
||||
const int nPageVert = viewport()->height();
|
||||
|
||||
if (nPageHorz == 0 || nPageVert == 0 || rowCount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QSize& borderSize = BorderSize();
|
||||
int x = borderSize.width();
|
||||
int y = borderSize.height();
|
||||
|
||||
QSize itemSize = ItemSize();
|
||||
const int nTextHeight = fontMetrics().height();
|
||||
const int xMax = nPageHorz - borderSize.width();
|
||||
int itemHeightMax = 0;
|
||||
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
QModelIndex index = m_model->index(row, 0);
|
||||
itemSize = index.data(Qt::SizeHintRole).toSize();
|
||||
|
||||
if ((x + itemSize.width()) > xMax)
|
||||
{
|
||||
y += itemHeightMax + borderSize.height() + nTextHeight;
|
||||
x = borderSize.width();
|
||||
itemHeightMax = 0;
|
||||
}
|
||||
|
||||
if (itemSize.height() > itemHeightMax)
|
||||
{
|
||||
itemHeightMax = itemSize.height();
|
||||
}
|
||||
|
||||
SetItemGeometry(index, QRect(QPoint(x, y), itemSize));
|
||||
|
||||
x += itemSize.width() + borderSize.width();
|
||||
}
|
||||
|
||||
verticalScrollBar()->setPageStep(viewport()->height());
|
||||
verticalScrollBar()->setRange(0, (y + itemHeightMax - viewport()->height()));
|
||||
}
|
||||
|
||||
QLensFlareAtomicListModel::QLensFlareAtomicListModel(QObject* parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QLensFlareAtomicListModel::~QLensFlareAtomicListModel()
|
||||
{
|
||||
}
|
||||
|
||||
void QLensFlareAtomicListModel::Clear()
|
||||
{
|
||||
qDeleteAll(m_items);
|
||||
m_items.clear();
|
||||
}
|
||||
|
||||
int QLensFlareAtomicListModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_items.count();
|
||||
}
|
||||
|
||||
QVariant QLensFlareAtomicListModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
Item* item;
|
||||
if (!index.isValid())
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
else
|
||||
{
|
||||
item = ItemFromIndex(index);
|
||||
if (!item)
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return item->text;
|
||||
|
||||
case Qt::SizeHintRole:
|
||||
return item->size;
|
||||
|
||||
case Qt::DecorationRole:
|
||||
return item->pixmap;
|
||||
|
||||
case Qt::UserRole:
|
||||
return item->flareType;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool QLensFlareAtomicListModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
Item* item;
|
||||
if (index.isValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
item = ItemFromIndex(index);
|
||||
if (!item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::EditRole:
|
||||
item->text = value.toString();
|
||||
break;
|
||||
|
||||
case Qt::DecorationRole:
|
||||
item->pixmap = value.value<QPixmap>();
|
||||
break;
|
||||
|
||||
case Qt::SizeHintRole:
|
||||
item->size = value.toSize();
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
emit dataChanged(index, index, QVector<int>() << role);
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::ItemFlags QLensFlareAtomicListModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
|
||||
}
|
||||
|
||||
EFlareType QLensFlareAtomicListModel::FlareTypeFromIndex(QModelIndex index) const
|
||||
{
|
||||
Item* item;
|
||||
if (!index.isValid())
|
||||
{
|
||||
return eFT_Max;
|
||||
}
|
||||
else
|
||||
{
|
||||
item = ItemFromIndex(index);
|
||||
if (!item)
|
||||
{
|
||||
return eFT_Max;
|
||||
}
|
||||
}
|
||||
|
||||
return item->flareType;
|
||||
}
|
||||
|
||||
QLensFlareAtomicListModel::Item* QLensFlareAtomicListModel::ItemFromIndex(QModelIndex index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return m_items.at(index.row());
|
||||
}
|
||||
|
||||
QStringList QLensFlareAtomicListModel::mimeTypes() const
|
||||
{
|
||||
return {
|
||||
QStringLiteral("application/x-o3de-flaretypes")
|
||||
};
|
||||
}
|
||||
|
||||
QMimeData* QLensFlareAtomicListModel::mimeData(const QModelIndexList& indexes) const
|
||||
{
|
||||
QMimeData* data = new QMimeData();
|
||||
|
||||
QByteArray encoded;
|
||||
QDataStream stream(&encoded, QIODevice::WriteOnly);
|
||||
|
||||
for (const QModelIndex& index : indexes)
|
||||
{
|
||||
stream << static_cast<int>(FlareTypeFromIndex(index));
|
||||
}
|
||||
|
||||
data->setData(QStringLiteral("application/x-o3de-flaretypes"), encoded);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
bool QLensFlareAtomicListModel::dropMimeData([[maybe_unused]] const QMimeData* data, [[maybe_unused]] Qt::DropAction action, [[maybe_unused]] int row, [[maybe_unused]] int column, [[maybe_unused]] const QModelIndex& parent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::DropActions QLensFlareAtomicListModel::supportedDragActions() const
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
|
||||
#include <LensFlareEditor/moc_LensFlareAtomicList.cpp>
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREATOMICLIST_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREATOMICLIST_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include "Controls/ImageListCtrl.h"
|
||||
#endif
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QAbstractItemModel>
|
||||
#include <QScopedPointer>
|
||||
#endif
|
||||
|
||||
class CLensFlareEditor;
|
||||
class QLensFlareAtomicListModel;
|
||||
|
||||
class CLensFlareAtomicList
|
||||
: public CImageListCtrl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CLensFlareAtomicList(QWidget* parent = nullptr);
|
||||
virtual ~CLensFlareAtomicList();
|
||||
|
||||
void FillAtomicItems();
|
||||
|
||||
protected:
|
||||
void updateGeometries() override;
|
||||
|
||||
private:
|
||||
QScopedPointer<QLensFlareAtomicListModel> m_model;
|
||||
};
|
||||
|
||||
class QLensFlareAtomicListModel
|
||||
: public QAbstractListModel
|
||||
{
|
||||
struct Item;
|
||||
Q_OBJECT
|
||||
public:
|
||||
QLensFlareAtomicListModel(QObject* parent = nullptr);
|
||||
~QLensFlareAtomicListModel();
|
||||
|
||||
void Clear();
|
||||
void Populate();
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
QStringList mimeTypes() const override;
|
||||
QMimeData* mimeData(const QModelIndexList& indexes) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
|
||||
EFlareType FlareTypeFromIndex(QModelIndex index) const;
|
||||
|
||||
protected:
|
||||
QModelIndex InsertItem(const FlareInfo& flareInfo);
|
||||
Item* ItemFromIndex(QModelIndex index) const;
|
||||
|
||||
private:
|
||||
QVector<Item*> m_items;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREATOMICLIST_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,233 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREEDITOR_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREEDITOR_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include "DatabaseFrameWnd.h"
|
||||
#include "LensFlareUtil.h"
|
||||
#include "ILensFlareListener.h"
|
||||
#include "LensFlareItemTree.h"
|
||||
#include "UserMessageDefines.h"
|
||||
#endif
|
||||
|
||||
#include <AzQtComponents/Components/DockMainWindow.h>
|
||||
|
||||
namespace AzQtComponents
|
||||
{
|
||||
class FancyDocking;
|
||||
}
|
||||
|
||||
class CLensFlareView;
|
||||
class CLensFlareElementTree;
|
||||
class CLensFlareAtomicList;
|
||||
class CLensFlareElementPropertyView;
|
||||
class CLensFlareItem;
|
||||
class CLensFlareLibrary;
|
||||
class ReflectedPropertyControl;
|
||||
class CLensFlareLightEntityTree;
|
||||
class CLensFlareReferenceTree;
|
||||
|
||||
class CLensFlareEditor
|
||||
: public CDatabaseFrameWnd
|
||||
, public ILensFlareChangeElementListener
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static const GUID& GetClassID();
|
||||
static void RegisterViewClass();
|
||||
|
||||
CLensFlareEditor(QWidget* pParent = nullptr);
|
||||
~CLensFlareEditor();
|
||||
|
||||
QMenu* createPopupMenu() override;
|
||||
|
||||
// CDatabaseFrameWnd overrides...
|
||||
virtual void SelectItem(CBaseLibraryItem* item, bool bForceReload = false) override;
|
||||
|
||||
CLensFlareItem* GetSelectedLensFlareItem() const;
|
||||
bool GetSelectedLensFlareName(QString& outName) const;
|
||||
void UpdateLensFlareItem(CLensFlareItem* pLensFlareItem);
|
||||
void ResetElementTreeControl();
|
||||
|
||||
CLensFlareLibrary* GetCurrentLibrary() const
|
||||
{
|
||||
if (m_pLibrary == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return (CLensFlareLibrary*)&(*m_pLibrary);
|
||||
}
|
||||
|
||||
bool IsExistTreeItem(const QString& name, bool bExclusiveSelectedItem = false);
|
||||
void RenameLensFlareItem(CLensFlareItem* pLensFlareItem, const QString& newGroupName, const QString& newShortName);
|
||||
|
||||
IOpticsElementBasePtr FindOptics(const QString& itemPath, const QString& opticsPath);
|
||||
|
||||
CLensFlareElementTree* GetLensFlareElementTree()
|
||||
{
|
||||
return m_pLensFlareElementTree;
|
||||
}
|
||||
|
||||
CLensFlareView* GetLensFlareView() const
|
||||
{
|
||||
return m_pLensFlareView;
|
||||
}
|
||||
|
||||
CLensFlareItemTree* GetLensFlareItemTree()
|
||||
{
|
||||
return m_LensFlareItemTree;
|
||||
}
|
||||
|
||||
void RemovePropertyItems();
|
||||
|
||||
ReflectedPropertyControl* GetPropertyCtrl()
|
||||
{
|
||||
return m_pWndProps;
|
||||
}
|
||||
|
||||
void UpdateLensOpticsNames(const QString& oldFullName, const QString& newFullName);
|
||||
void SelectItemInLensFlareElementTreeByName(const QString& name);
|
||||
void ReloadItems();
|
||||
|
||||
void RegisterLensFlareItemChangeListener(ILensFlareChangeItemListener* pListener);
|
||||
void UnregisterLensFlareItemChangeListener(ILensFlareChangeItemListener* pListener);
|
||||
|
||||
bool SelectItemByName(const QString& itemName);
|
||||
|
||||
static CLensFlareEditor* GetLensFlareEditor()
|
||||
{
|
||||
return s_pLensFlareEditor;
|
||||
}
|
||||
|
||||
bool GetFullSelectedFlareItemName(QString& outFullName) const
|
||||
{
|
||||
QModelIndexList selected = GetTreeCtrl()->selectionModel()->selectedIndexes();
|
||||
if (selected.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return GetFullLensFlareItemName(selected.first(), outFullName);
|
||||
}
|
||||
|
||||
void SelectLensFlareItem(const QString& fullItemName);
|
||||
|
||||
const char* GetClassName()
|
||||
{
|
||||
return s_pLensFlareEditorClassName;
|
||||
}
|
||||
|
||||
void Paste(XmlNodeRef node);
|
||||
void Paste(const QModelIndex& index, XmlNodeRef node);
|
||||
XmlNodeRef CreateXML(const char* type) const;
|
||||
|
||||
static const char* s_pLensFlareEditorClassName;
|
||||
|
||||
QTreeView* GetTreeCtrl() override
|
||||
{
|
||||
return m_LensFlareItemTree;
|
||||
}
|
||||
|
||||
const QTreeView* GetTreeCtrl() const override
|
||||
{
|
||||
return m_LensFlareItemTree;
|
||||
}
|
||||
|
||||
void AddNewItemByAtomicOptics(const QModelIndex& hSelectedItem, EFlareType flareType);
|
||||
|
||||
public slots:
|
||||
void OnUpdateTreeCtrl();
|
||||
|
||||
protected:
|
||||
static CLensFlareEditor* s_pLensFlareEditor;
|
||||
|
||||
void OnInitDialog() override;
|
||||
|
||||
void OnCopy();
|
||||
void OnPaste();
|
||||
void OnCut();
|
||||
|
||||
void UpdateClipboard(const char* type) const;
|
||||
bool GetClipboardDataList(std::vector<LensFlareUtil::SClipboardData>& outList, QString& outGroupName) const;
|
||||
void OnLensFlareChangeElement(CLensFlareElement* pLensFlareElement);
|
||||
|
||||
void OnAddLibrary();
|
||||
void OnAssignFlareToLightEntities();
|
||||
void OnSelectAssignedObjects();
|
||||
void OnGetFlareFromSelection();
|
||||
void OnRenameItem();
|
||||
void OnAddItem();
|
||||
void OnRemoveItem();
|
||||
void OnCopyNameToClipboard();
|
||||
void OnNotifyTreeRClick();
|
||||
|
||||
void OnTvnItemSelChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
||||
void OnReloadLib();
|
||||
void ReleaseWindowsToBePutIntoPanels();
|
||||
void SelectLensFlareItem(const QModelIndex& hItem);
|
||||
void SelectLensFlareItem(const QModelIndex& hItem, const QModelIndex& hPrevItem);
|
||||
|
||||
void StartEditItem(const QModelIndex& hItem);
|
||||
bool GetFullLensFlareItemName(const QModelIndex& hItem, QString& outFullName) const;
|
||||
AssetSelectionModel GetAssetSelectionModel() const override;
|
||||
|
||||
CLensFlareItem* AddNewLensFlareItem(const QString& groupName, const QString& shortName);
|
||||
QModelIndex GetTreeLensFlareItem(CLensFlareItem* pItem) const;
|
||||
|
||||
void OnItemTreeDataRenamed(CBaseLibraryItem* pItem, const QString& prevFullName);
|
||||
|
||||
enum ESelectedItemStatus
|
||||
{
|
||||
eSIS_Unselected,
|
||||
eSIS_Group,
|
||||
eSIS_Flare
|
||||
};
|
||||
ESelectedItemStatus GetSelectedItemStatus() const;
|
||||
|
||||
void addDockWidget(Qt::DockWidgetArea area, QWidget* widget, const QString& title, bool closable = true);
|
||||
void OnUpdateProperties(IVariable* var);
|
||||
|
||||
private:
|
||||
|
||||
CLensFlareView* m_pLensFlareView;
|
||||
CLensFlareAtomicList* m_pLensFlareAtomicList;
|
||||
CLensFlareElementTree* m_pLensFlareElementTree;
|
||||
ReflectedPropertyControl* m_pWndProps;
|
||||
CLensFlareLightEntityTree* m_pLensFlareLightEntityTree;
|
||||
CLensFlareReferenceTree* m_pLensFlareReferenceTree;
|
||||
CLensFlareItemTree* m_LensFlareItemTree;
|
||||
|
||||
std::vector<ILensFlareChangeItemListener*> m_LensFlareChangeItemListenerList;
|
||||
AzQtComponents::FancyDocking* m_advancedDockManager = nullptr;
|
||||
};
|
||||
|
||||
class LensFlareItemTreeModel
|
||||
: public LibraryItemTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LensFlareItemTreeModel(CDatabaseFrameWnd* pParent);
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
QStringList mimeTypes() const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREEDITOR_H
|
||||
@@ -1,381 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LensFlareElement.h"
|
||||
|
||||
// Editor
|
||||
#include "LensFlareElementTree.h"
|
||||
#include "LensFlareUtil.h"
|
||||
#include "LensFlareItem.h"
|
||||
#include "LensFlareEditor.h"
|
||||
#include "LensFlareView.h"
|
||||
#include "LensFlareLibrary.h"
|
||||
|
||||
|
||||
CLensFlareElement::CLensFlareElement()
|
||||
: m_vars(NULL)
|
||||
, m_pOpticsElement(NULL)
|
||||
, m_pParent(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CLensFlareElement::~CLensFlareElement()
|
||||
{
|
||||
}
|
||||
|
||||
void CLensFlareElement::OnInternalVariableChange(IVariable* pVar)
|
||||
{
|
||||
IOpticsElementBasePtr pOptics = GetOpticsElement();
|
||||
if (pOptics == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IFuncVariable* pFuncVar = LensFlareUtil::GetFuncVariable(pOptics, pVar->GetUserData().toInt());
|
||||
if (pFuncVar == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pVar->GetType())
|
||||
{
|
||||
case IVariable::INT:
|
||||
{
|
||||
int var(0);
|
||||
pVar->Get(var);
|
||||
if (pFuncVar->paramType == e_COLOR)
|
||||
{
|
||||
ColorF color(pFuncVar->GetColorF());
|
||||
color.a = (float)var / 255.0f;
|
||||
pFuncVar->InvokeSetter((void*)&color);
|
||||
}
|
||||
else if (pFuncVar->paramType == e_INT)
|
||||
{
|
||||
if (LensFlareUtil::HaveParameterLowBoundary(pFuncVar->name.c_str()))
|
||||
{
|
||||
LensFlareUtil::BoundaryProcess(var);
|
||||
}
|
||||
pFuncVar->InvokeSetter((void*)&var);
|
||||
if (pFuncVar->GetInt() != var)
|
||||
{
|
||||
pVar->Set(pFuncVar->GetInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IVariable::BOOL:
|
||||
{
|
||||
if (pFuncVar->paramType == e_BOOL)
|
||||
{
|
||||
bool var;
|
||||
pVar->Get(var);
|
||||
pFuncVar->InvokeSetter((void*)&var);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IVariable::FLOAT:
|
||||
{
|
||||
if (pFuncVar->paramType == e_FLOAT)
|
||||
{
|
||||
float var;
|
||||
pVar->Get(var);
|
||||
pFuncVar->InvokeSetter((void*)&var);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IVariable::VECTOR2:
|
||||
{
|
||||
if (pFuncVar->paramType == e_VEC2)
|
||||
{
|
||||
Vec2 var;
|
||||
pVar->Get(var);
|
||||
pFuncVar->InvokeSetter((void*)&var);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IVariable::VECTOR:
|
||||
{
|
||||
Vec3 var;
|
||||
pVar->Get(var);
|
||||
if (pFuncVar->paramType == e_COLOR)
|
||||
{
|
||||
ColorF color(pFuncVar->GetColorF());
|
||||
color.r = var.x;
|
||||
color.g = var.y;
|
||||
color.b = var.z;
|
||||
pFuncVar->InvokeSetter((void*)&color);
|
||||
}
|
||||
else if (pFuncVar->paramType == e_VEC3)
|
||||
{
|
||||
pFuncVar->InvokeSetter((void*)&var);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IVariable::VECTOR4:
|
||||
{
|
||||
if (pFuncVar->paramType == e_VEC4)
|
||||
{
|
||||
Vec4 var;
|
||||
pVar->Get(var);
|
||||
pFuncVar->InvokeSetter((void*)&var);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IVariable::STRING:
|
||||
{
|
||||
QString var;
|
||||
pVar->Get(var);
|
||||
if (pFuncVar->paramType == e_TEXTURE2D || pFuncVar->paramType == e_TEXTURE3D || pFuncVar->paramType == e_TEXTURE_CUBE)
|
||||
{
|
||||
var = var.trimmed();
|
||||
ITexture* pTexture = NULL;
|
||||
if (!var.isEmpty())
|
||||
{
|
||||
pTexture = GetIEditor()->GetRenderer()->EF_LoadTexture(var.toUtf8().data());
|
||||
}
|
||||
pFuncVar->InvokeSetter((void*)pTexture);
|
||||
if (pTexture)
|
||||
{
|
||||
pTexture->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateLights();
|
||||
}
|
||||
|
||||
bool CLensFlareElement::IsEnable()
|
||||
{
|
||||
IOpticsElementBasePtr pOptics = GetOpticsElement();
|
||||
if (pOptics == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return pOptics->IsEnabled();
|
||||
}
|
||||
|
||||
void CLensFlareElement::SetEnable(bool bEnable)
|
||||
{
|
||||
IOpticsElementBasePtr pOptics = GetOpticsElement();
|
||||
if (pOptics == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pOptics->SetEnabled(bEnable);
|
||||
UpdateLights();
|
||||
}
|
||||
|
||||
EFlareType CLensFlareElement::GetOpticsType()
|
||||
{
|
||||
IOpticsElementBasePtr pOptics = GetOpticsElement();
|
||||
if (pOptics == NULL)
|
||||
{
|
||||
return eFT__Base__;
|
||||
}
|
||||
return pOptics->GetType();
|
||||
}
|
||||
|
||||
bool CLensFlareElement::GetShortName(QString& outName) const
|
||||
{
|
||||
QString fullName;
|
||||
if (!GetName(fullName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int nPos = fullName.lastIndexOf('.');
|
||||
if (nPos == -1)
|
||||
{
|
||||
outName = fullName;
|
||||
return true;
|
||||
}
|
||||
outName = fullName.right(fullName.length() - nPos - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CLensFlareElement::UpdateLights()
|
||||
{
|
||||
IOpticsElementBasePtr pOptics = GetOpticsElement();
|
||||
if (pOptics == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (GetLensFlareTree())
|
||||
{
|
||||
if (GetLensFlareTree()->GetLensFlareItem())
|
||||
{
|
||||
GetLensFlareTree()->GetLensFlareItem()->UpdateLights(pOptics);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLensFlareElement::UpdateProperty(IOpticsElementBasePtr pOptics)
|
||||
{
|
||||
std::vector<IVariable::OnSetCallback*> funcs;
|
||||
|
||||
if (CLensFlareElementTree* lensFlareTree = GetLensFlareTree(); lensFlareTree)
|
||||
{
|
||||
auto callbackItr = m_callbackCache.find(lensFlareTree);
|
||||
if (callbackItr == m_callbackCache.end())
|
||||
{
|
||||
IVariable::OnSetCallback callback =
|
||||
AZStd::bind(&CLensFlareElementTree::OnInternalVariableChange, lensFlareTree, AZStd::placeholders::_1);
|
||||
|
||||
auto result = m_callbackCache.insert(AZStd::make_pair(lensFlareTree, callback));
|
||||
callbackItr = result.first;
|
||||
}
|
||||
|
||||
funcs.push_back(&(callbackItr->second));
|
||||
}
|
||||
|
||||
if (CLensFlareView* lensFlareView = GetLensFlareView(); lensFlareView)
|
||||
{
|
||||
auto callbackItr = m_callbackCache.find(lensFlareView);
|
||||
if (callbackItr == m_callbackCache.end())
|
||||
{
|
||||
IVariable::OnSetCallback callback =
|
||||
AZStd::bind(&CLensFlareView::OnInternalVariableChange, lensFlareView, AZStd::placeholders::_1);
|
||||
|
||||
auto result = m_callbackCache.insert(AZStd::make_pair(lensFlareView, callback));
|
||||
callbackItr = result.first;
|
||||
}
|
||||
|
||||
funcs.push_back(&(callbackItr->second));
|
||||
}
|
||||
|
||||
if (CLensFlareLibrary* lensFlareLibrary = GetLensFlareLibrary(); lensFlareLibrary)
|
||||
{
|
||||
auto callbackItr = m_callbackCache.find(lensFlareLibrary);
|
||||
if (callbackItr == m_callbackCache.end())
|
||||
{
|
||||
IVariable::OnSetCallback callback =
|
||||
AZStd::bind(&CLensFlareLibrary::OnInternalVariableChange, lensFlareLibrary, AZStd::placeholders::_1);
|
||||
|
||||
auto result = m_callbackCache.insert(AZStd::make_pair(lensFlareLibrary, callback));
|
||||
callbackItr = result.first;
|
||||
}
|
||||
|
||||
funcs.push_back(&(callbackItr->second));
|
||||
}
|
||||
|
||||
LensFlareUtil::SetVariablesTemplateFromOptics(pOptics, m_vars, funcs);
|
||||
}
|
||||
|
||||
CLensFlareElementTree* CLensFlareElement::GetLensFlareTree() const
|
||||
{
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return pEditor->GetLensFlareElementTree();
|
||||
}
|
||||
|
||||
CLensFlareView* CLensFlareElement::GetLensFlareView() const
|
||||
{
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return pEditor->GetLensFlareView();
|
||||
}
|
||||
|
||||
CLensFlareLibrary* CLensFlareElement::GetLensFlareLibrary() const
|
||||
{
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return pEditor->GetCurrentLibrary();
|
||||
}
|
||||
|
||||
CLensFlareElement* CLensFlareElement::GetParent() const
|
||||
{
|
||||
return m_pParent;
|
||||
}
|
||||
|
||||
void CLensFlareElement::SetParent(CLensFlareElement* pParent)
|
||||
{
|
||||
m_pParent = pParent;
|
||||
}
|
||||
|
||||
int CLensFlareElement::GetChildCount() const
|
||||
{
|
||||
return m_children.size();
|
||||
}
|
||||
|
||||
CLensFlareElement* CLensFlareElement::GetChildAt(int nPos) const
|
||||
{
|
||||
if (nPos < 0 || nPos >= m_children.size())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return m_children[nPos];
|
||||
}
|
||||
|
||||
void CLensFlareElement::AddChild(CLensFlareElement* pElement)
|
||||
{
|
||||
pElement->SetParent(this);
|
||||
m_children.push_back(pElement);
|
||||
}
|
||||
|
||||
void CLensFlareElement::InsertChild(int nPos, CLensFlareElement* pElement)
|
||||
{
|
||||
pElement->SetParent(this);
|
||||
m_children.insert(std::begin(m_children) + nPos, pElement);
|
||||
}
|
||||
|
||||
void CLensFlareElement::RemoveChild(int nPos)
|
||||
{
|
||||
m_children.erase(std::begin(m_children) + nPos);
|
||||
}
|
||||
|
||||
void CLensFlareElement::SwapChildren(int nPos1, int nPos2)
|
||||
{
|
||||
std::swap(m_children[nPos1], m_children[nPos2]);
|
||||
}
|
||||
|
||||
void CLensFlareElement::RemoveAllChildren()
|
||||
{
|
||||
m_children.clear();
|
||||
}
|
||||
|
||||
int CLensFlareElement::GetChildIndex(const CLensFlareElement* pElement) const
|
||||
{
|
||||
auto it = std::find_if(
|
||||
std::begin(m_children),
|
||||
std::end(m_children),
|
||||
[=](const LensFlareElementPtr& pChild)
|
||||
{
|
||||
return pChild.get() == pElement;
|
||||
});
|
||||
|
||||
if (it != std::end(m_children))
|
||||
{
|
||||
return std::distance(std::begin(m_children), it);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int CLensFlareElement::GetRow() const
|
||||
{
|
||||
return m_pParent ? m_pParent->GetChildIndex(this) : 0;
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENT_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENT_H
|
||||
#pragma once
|
||||
|
||||
#include "IFlares.h"
|
||||
|
||||
#include "Util/Variable.h"
|
||||
|
||||
class CLensFlareElementTree;
|
||||
class CLensFlareView;
|
||||
class CLensFlareLibrary;
|
||||
|
||||
class CLensFlareElement
|
||||
: public CRefCountBase
|
||||
{
|
||||
public:
|
||||
|
||||
typedef _smart_ptr<CLensFlareElement> LensFlareElementPtr;
|
||||
typedef std::vector<LensFlareElementPtr> LensFlareElementList;
|
||||
|
||||
CLensFlareElement();
|
||||
virtual ~CLensFlareElement();
|
||||
|
||||
CVarBlock* GetProperties() const
|
||||
{
|
||||
return m_vars;
|
||||
}
|
||||
|
||||
void OnInternalVariableChange(IVariable* pVar);
|
||||
|
||||
bool IsEnable();
|
||||
void SetEnable(bool bEnable);
|
||||
EFlareType GetOpticsType();
|
||||
|
||||
bool GetName(QString& outName) const
|
||||
{
|
||||
IOpticsElementBasePtr pOptics = GetOpticsElement();
|
||||
if (pOptics == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
outName = pOptics->GetName();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetShortName(QString& outName) const;
|
||||
IOpticsElementBasePtr GetOpticsElement() const
|
||||
{
|
||||
return m_pOpticsElement;
|
||||
}
|
||||
void SetOpticsElement(IOpticsElementBasePtr pOptics)
|
||||
{
|
||||
m_pOpticsElement = pOptics;
|
||||
UpdateProperty(m_pOpticsElement);
|
||||
}
|
||||
|
||||
CLensFlareElement* GetParent() const;
|
||||
void SetParent(CLensFlareElement* pParent);
|
||||
|
||||
int GetChildCount() const;
|
||||
CLensFlareElement* GetChildAt(int nPos) const;
|
||||
|
||||
void AddChild(CLensFlareElement* pElement);
|
||||
void InsertChild(int nPos, CLensFlareElement* pElement);
|
||||
|
||||
void RemoveChild(int nPos);
|
||||
void RemoveAllChildren();
|
||||
|
||||
void SwapChildren(int nPos1, int nPos2);
|
||||
|
||||
int GetChildIndex(const CLensFlareElement* pChild) const;
|
||||
int GetRow() const;
|
||||
|
||||
private:
|
||||
|
||||
void UpdateLights();
|
||||
void UpdateProperty(IOpticsElementBasePtr pOptics);
|
||||
|
||||
CLensFlareElementTree* GetLensFlareTree() const;
|
||||
CLensFlareView* GetLensFlareView() const;
|
||||
CLensFlareLibrary* GetLensFlareLibrary() const;
|
||||
|
||||
private:
|
||||
|
||||
IOpticsElementBasePtr m_pOpticsElement;
|
||||
CVarBlockPtr m_vars;
|
||||
|
||||
CLensFlareElement* m_pParent;
|
||||
LensFlareElementList m_children;
|
||||
|
||||
AZStd::map<void*, IVariable::OnSetCallback> m_callbackCache;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENT_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,197 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENTTREE_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENTTREE_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include "LensFlareElement.h"
|
||||
#include "LensFlareUtil.h"
|
||||
#include "ILensFlareListener.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QTreeView>
|
||||
#endif
|
||||
|
||||
class CLensFlareItem;
|
||||
class LensFlareElementTreeModel;
|
||||
class QMouseEvent;
|
||||
|
||||
class CLensFlareElementTree
|
||||
: public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
CLensFlareElementTree(QWidget* pParent = nullptr);
|
||||
|
||||
void RegisterListener(ILensFlareChangeElementListener* pListener)
|
||||
{
|
||||
if (pListener)
|
||||
{
|
||||
m_LensFlaresElementListeners.push_back(pListener);
|
||||
}
|
||||
}
|
||||
|
||||
void UnregisterListener(ILensFlareChangeElementListener* pListener)
|
||||
{
|
||||
if (pListener == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
std::vector<ILensFlareChangeElementListener*>::iterator ii = m_LensFlaresElementListeners.begin();
|
||||
for (; ii != m_LensFlaresElementListeners.end(); )
|
||||
{
|
||||
if (*ii == pListener)
|
||||
{
|
||||
ii = m_LensFlaresElementListeners.erase(ii);
|
||||
}
|
||||
else
|
||||
{
|
||||
++ii;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CLensFlareElement::LensFlareElementPtr FindLensFlareElement(IOpticsElementBasePtr pElement) const;
|
||||
|
||||
void OnInternalVariableChange(IVariable* pVar);
|
||||
|
||||
CLensFlareElement* GetCurrentLensFlareElement() const;
|
||||
void UpdateProperty();
|
||||
void UpdateClipboard(const char* type, bool bPasteAtSameLevel);
|
||||
|
||||
void SelectTreeItemByName(const QString& name);
|
||||
|
||||
CLensFlareItem* GetLensFlareItem() const;
|
||||
void InvalidateLensFlareItem();
|
||||
|
||||
protected:
|
||||
void CallChangeListeners();
|
||||
|
||||
void OnDataChanged(const QModelIndex& index);
|
||||
void OnRowsInserted(const QModelIndex& index, int first, int last);
|
||||
void OnRowsRemoved(const QModelIndex& index, int first, int last);
|
||||
|
||||
void OnNotifyTreeRClick();
|
||||
void OnTvnSelchangedTree(const QItemSelection& selected, const QItemSelection& deselected);
|
||||
|
||||
XmlNodeRef CreateXML(const char* type) const;
|
||||
bool GetClipboardList(const char* type, std::vector<LensFlareUtil::SClipboardData>& outList) const;
|
||||
|
||||
//! Only the basic operations like following methods must have routine for undoing.
|
||||
void ElementChanged(CLensFlareElement* pPrevLensFlareElement);
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OnAddGroup();
|
||||
void OnCopy();
|
||||
void OnCut();
|
||||
void OnPaste();
|
||||
void OnClone();
|
||||
void OnRenameItem();
|
||||
void OnRemoveItem();
|
||||
void OnRemoveAll();
|
||||
void OnItemUp();
|
||||
void OnItemDown();
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
void Cut(bool bPasteAtSameLevel);
|
||||
|
||||
private:
|
||||
void SelectItem(const QModelIndex& index);
|
||||
|
||||
std::vector<ILensFlareChangeElementListener*> m_LensFlaresElementListeners;
|
||||
|
||||
QScopedPointer<LensFlareElementTreeModel> m_model;
|
||||
};
|
||||
|
||||
class LensFlareElementTreeModel
|
||||
: public QAbstractItemModel
|
||||
, public ILensFlareChangeItemListener
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LensFlareElementTreeModel(QObject* pParent = nullptr);
|
||||
~LensFlareElementTreeModel();
|
||||
|
||||
int rowCount(const QModelIndex& parent = {}) const override;
|
||||
int columnCount(const QModelIndex& parent = {}) const override;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
||||
|
||||
QModelIndex index(int row, int column, const QModelIndex& parent = {}) const override;
|
||||
QModelIndex parent(const QModelIndex& index) const override;
|
||||
|
||||
bool removeRows(int row, int count, const QModelIndex& parent = {}) override;
|
||||
|
||||
QStringList mimeTypes() const override;
|
||||
QMimeData* mimeData(const QModelIndexList& indexes) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
|
||||
CLensFlareElement* GetLensFlareElement(const QModelIndex& index) const;
|
||||
|
||||
QModelIndex GetTreeItemByName(const QString& name) const;
|
||||
|
||||
void Paste(const QModelIndex& index, XmlNodeRef xmlNode);
|
||||
void Cut(const QModelIndex& index, bool bPasteAtSameLevel);
|
||||
|
||||
CLensFlareItem* GetLensFlareItem() const
|
||||
{
|
||||
return m_pLensFlareItem;
|
||||
}
|
||||
|
||||
void InvalidateLensFlareItem();
|
||||
|
||||
void RemoveAllElements();
|
||||
bool AddElement(const QModelIndex& index, int row, EFlareType flareType);
|
||||
|
||||
bool MoveElement(CLensFlareElement* pElement, int row, const QModelIndex& parentIndex);
|
||||
|
||||
private:
|
||||
QModelIndex GetRootItem() const;
|
||||
IOpticsElementBasePtr GetOpticsElementByTreeItem(const QModelIndex& index) const;
|
||||
|
||||
void OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem);
|
||||
void OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem);
|
||||
|
||||
void UpdateLensFlareItem(CLensFlareItem* pLensFlareItem);
|
||||
CLensFlareElement* UpdateLensFlareElementsRecusively(IOpticsElementBasePtr pOptics);
|
||||
CLensFlareElement* CreateElement(IOpticsElementBasePtr pOptics);
|
||||
void Reload();
|
||||
|
||||
void MakeValidElementName(const QString& seedName, QString& outValidName) const;
|
||||
bool IsExistElement(const QString& name) const;
|
||||
CLensFlareElement::LensFlareElementPtr InsertAtomicElement(int nIndex, EFlareType flareType, CLensFlareElement* pParentElement);
|
||||
CLensFlareElement::LensFlareElementPtr AddElement(IOpticsElementBasePtr pOptics, CLensFlareElement* pParentElement);
|
||||
CLensFlareElement* FindLensFlareElement(IOpticsElementBasePtr pOptics) const;
|
||||
|
||||
QModelIndex GetTreeItemByOpticsElement(const IOpticsElementBasePtr pOptics) const;
|
||||
void EnableElement(CLensFlareElement* pLensFlareElement, bool bEnable);
|
||||
void RenameElement(CLensFlareElement* pLensFlareElement, const QString& newName);
|
||||
void StoreUndo(const QString& undoDescription = "");
|
||||
|
||||
CLensFlareElement::LensFlareElementPtr m_pRootElement;
|
||||
CLensFlareItem* m_pLensFlareItem;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(CLensFlareElement*)
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENTTREE_H
|
||||
@@ -1,203 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LensFlareItem.h"
|
||||
|
||||
// Editor
|
||||
#include "LensFlareUtil.h"
|
||||
#include "LensFlareEditor.h"
|
||||
#include "LensFlareUndo.h"
|
||||
#include "Objects/EntityObject.h"
|
||||
|
||||
|
||||
CLensFlareItem::CLensFlareItem()
|
||||
{
|
||||
m_pOptics = NULL;
|
||||
CreateOptics();
|
||||
}
|
||||
|
||||
CLensFlareItem::~CLensFlareItem()
|
||||
{
|
||||
}
|
||||
|
||||
void CLensFlareItem::Serialize(SerializeContext& ctx)
|
||||
{
|
||||
if (ctx.bLoading)
|
||||
{
|
||||
CreateOptics();
|
||||
LensFlareUtil::FillOpticsFromXML(m_pOptics, ctx.node);
|
||||
|
||||
for (int i = 0, iChildCount(ctx.node->getChildCount()); i < iChildCount; ++i)
|
||||
{
|
||||
AddChildOptics(m_pOptics, ctx.node->getChild(i));
|
||||
}
|
||||
|
||||
CBaseLibraryItem::Serialize(ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
CBaseLibraryItem::Serialize(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
void CLensFlareItem::AddChildOptics(IOpticsElementBasePtr pParentOptics, const XmlNodeRef& pNode)
|
||||
{
|
||||
if (pNode == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (pNode->getTag() && strcmp(pNode->getTag(), "FlareItem"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IOpticsElementBasePtr pOptics = LensFlareUtil::CreateOptics(pNode);
|
||||
if (pOptics == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pParentOptics->AddElement(pOptics);
|
||||
|
||||
for (int i = 0, iChildCount(pNode->getChildCount()); i < iChildCount; ++i)
|
||||
{
|
||||
AddChildOptics(pOptics, pNode->getChild(i));
|
||||
}
|
||||
}
|
||||
|
||||
void CLensFlareItem::CreateOptics()
|
||||
{
|
||||
m_pOptics = gEnv->pOpticsManager->Create(eFT_Root);
|
||||
}
|
||||
|
||||
XmlNodeRef CLensFlareItem::CreateXmlData() const
|
||||
{
|
||||
XmlNodeRef pRootNode = NULL;
|
||||
if (LensFlareUtil::CreateXmlData(m_pOptics, pRootNode))
|
||||
{
|
||||
pRootNode->setAttr("Name", m_pOptics->GetName().c_str());
|
||||
return pRootNode;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CLensFlareItem::SetName(const QString& name)
|
||||
{
|
||||
QString newNameWithGroup;
|
||||
QString newFullName;
|
||||
LensFlareUtil::GetExpandedItemNames(this, LensFlareUtil::GetGroupNameFromName(name), LensFlareUtil::GetShortName(name), newNameWithGroup, newFullName);
|
||||
|
||||
if (CUndo::IsRecording())
|
||||
{
|
||||
CUndo::Record(new CUndoRenameLensFlareItem(GetFullName(), newFullName));
|
||||
}
|
||||
|
||||
CBaseLibraryItem::SetName(name);
|
||||
|
||||
if (m_pOptics)
|
||||
{
|
||||
m_pOptics->SetName(GetShortName().toUtf8().data());
|
||||
}
|
||||
}
|
||||
|
||||
void CLensFlareItem::UpdateLights(IOpticsElementBasePtr pSrcOptics)
|
||||
{
|
||||
QString srcFullOpticsName = GetFullName();
|
||||
bool bUpdateChildren = false;
|
||||
if (pSrcOptics == NULL)
|
||||
{
|
||||
if (m_pOptics == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pSrcOptics = m_pOptics;
|
||||
bUpdateChildren = true;
|
||||
}
|
||||
|
||||
std::vector<CEntityObject*> lightEntities;
|
||||
LensFlareUtil::GetLightEntityObjects(lightEntities);
|
||||
|
||||
for (int i = 0, iLightSize(lightEntities.size()); i < iLightSize; ++i)
|
||||
{
|
||||
CEntityObject* pLightEntity = lightEntities[i];
|
||||
if (pLightEntity == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IOpticsElementBasePtr pTargetOptics = pLightEntity->GetOpticsElement();
|
||||
if (pTargetOptics == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QString targetFullOpticsName(pTargetOptics->GetName().c_str());
|
||||
if (srcFullOpticsName != targetFullOpticsName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QString srcOpticsName(pSrcOptics->GetName().c_str());
|
||||
IOpticsElementBasePtr pFoundOptics = NULL;
|
||||
if (LensFlareUtil::GetShortName(targetFullOpticsName) == srcOpticsName)
|
||||
{
|
||||
pFoundOptics = pTargetOptics;
|
||||
}
|
||||
else
|
||||
{
|
||||
pFoundOptics = LensFlareUtil::FindOptics(pTargetOptics, srcOpticsName);
|
||||
}
|
||||
|
||||
if (pFoundOptics == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (pFoundOptics->GetType() != pSrcOptics->GetType())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
LensFlareUtil::CopyOptics(pSrcOptics, pFoundOptics, bUpdateChildren);
|
||||
}
|
||||
}
|
||||
|
||||
void CLensFlareItem::ReplaceOptics(IOpticsElementBasePtr pNewData)
|
||||
{
|
||||
if (pNewData == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (pNewData->GetType() != eFT_Root)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CreateOptics();
|
||||
LensFlareUtil::CopyOptics(pNewData, m_pOptics);
|
||||
m_pOptics->SetName(GetFullName().toUtf8().data());
|
||||
UpdateLights();
|
||||
|
||||
CLensFlareEditor* pLensFlareEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pLensFlareEditor == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this != pLensFlareEditor->GetSelectedLensFlareItem())
|
||||
{
|
||||
return;
|
||||
}
|
||||
pLensFlareEditor->UpdateLensFlareItem(this);
|
||||
pLensFlareEditor->RemovePropertyItems();
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEM_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEM_H
|
||||
#pragma once
|
||||
|
||||
class IOpticsElementBase;
|
||||
class CEntityObject;
|
||||
|
||||
#include "BaseLibraryItem.h"
|
||||
#include "Include/IDataBaseItem.h"
|
||||
|
||||
class CLensFlareItem
|
||||
: public CBaseLibraryItem
|
||||
{
|
||||
public:
|
||||
|
||||
CLensFlareItem();
|
||||
~CLensFlareItem();
|
||||
|
||||
EDataBaseItemType GetType() const
|
||||
{
|
||||
return EDB_TYPE_FLARE;
|
||||
}
|
||||
|
||||
void SetName(const QString& name);
|
||||
void Serialize(SerializeContext& ctx);
|
||||
|
||||
void CreateOptics();
|
||||
|
||||
IOpticsElementBasePtr GetOptics() const
|
||||
{
|
||||
return m_pOptics;
|
||||
}
|
||||
|
||||
void ReplaceOptics(IOpticsElementBasePtr pNewData);
|
||||
|
||||
XmlNodeRef CreateXmlData() const;
|
||||
void UpdateLights(IOpticsElementBasePtr pSrcOptics = NULL);
|
||||
|
||||
private:
|
||||
|
||||
void GetLightEntityObjects(std::vector<CEntityObject*>& outEntityLights) const;
|
||||
static void AddChildOptics(IOpticsElementBasePtr pParentOptics, const XmlNodeRef& pNode);
|
||||
|
||||
IOpticsElementBasePtr m_pOptics;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEM_H
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LensFlareItemTree.h"
|
||||
|
||||
// Editor
|
||||
#include "LensFlareItem.h"
|
||||
#include "ViewManager.h"
|
||||
#include "Objects/EntityObject.h"
|
||||
|
||||
|
||||
CLensFlareItemTree::CLensFlareItemTree(QWidget* pParent)
|
||||
: QTreeView(pParent)
|
||||
{
|
||||
setHeaderHidden(true);
|
||||
setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
setDragEnabled(true);
|
||||
setAcceptDrops(true);
|
||||
setDropIndicatorShown(true);
|
||||
setDragDropMode(DragDrop);
|
||||
}
|
||||
|
||||
CLensFlareItemTree::~CLensFlareItemTree()
|
||||
{
|
||||
}
|
||||
|
||||
void CLensFlareItemTree::startDrag(Qt::DropActions supportedDropActions)
|
||||
{
|
||||
QTreeView::startDrag(supportedDropActions);
|
||||
}
|
||||
|
||||
void CLensFlareItemTree::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
CUndo undo(tr("Changed lens flare item").toUtf8());
|
||||
QTreeView::mousePressEvent(event);
|
||||
}
|
||||
else
|
||||
{
|
||||
QTreeView::mousePressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void CLensFlareItemTree::AssignLensFlareToLightEntity(CViewport* pViewport) const
|
||||
{
|
||||
QModelIndexList selected = selectionModel()->selectedIndexes();
|
||||
if (selected.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CLensFlareItem* pLensFlareItem = static_cast<CLensFlareItem*>(selected.first().data(Qt::UserRole).value<CBaseLibraryItem*>());
|
||||
|
||||
QPoint viewportPos = QCursor::pos();
|
||||
pViewport->ScreenToClient(viewportPos);
|
||||
HitContext hit;
|
||||
if (!pViewport->HitTest(viewportPos, hit))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (hit.object && qobject_cast<CEntityObject*>(hit.object))
|
||||
{
|
||||
CEntityObject* pEntity = (CEntityObject*)hit.object;
|
||||
if (pEntity->IsLight())
|
||||
{
|
||||
CUndo undo(tr("Assign a lens flare item to a light entity").toUtf8());
|
||||
pEntity->ApplyOptics(pLensFlareItem->GetFullName(), pLensFlareItem->GetOptics());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <LensFlareEditor/moc_LensFlareItemTree.cpp>
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEMTREE_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEMTREE_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include "LensFlareElement.h"
|
||||
#include "ILensFlareListener.h"
|
||||
|
||||
#include <QTreeView>
|
||||
#endif
|
||||
|
||||
class QMouseEvent;
|
||||
class CLensFlareItem;
|
||||
|
||||
class CLensFlareItemTree
|
||||
: public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CLensFlareItemTree(QWidget* pParent = nullptr);
|
||||
~CLensFlareItemTree();
|
||||
|
||||
protected:
|
||||
void startDrag(Qt::DropActions supportedDropActions) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
|
||||
private:
|
||||
|
||||
void AssignLensFlareToLightEntity(CViewport* pViewport) const;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREITEMTREE_H
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LensFlareLibrary.h"
|
||||
|
||||
// Editor
|
||||
#include "LensFlareItem.h"
|
||||
|
||||
|
||||
bool CLensFlareLibrary::Save()
|
||||
{
|
||||
return SaveLibrary("LensFlareLibrary");
|
||||
}
|
||||
|
||||
bool CLensFlareLibrary::Load(const QString& filename)
|
||||
{
|
||||
if (filename.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SetFilename(filename);
|
||||
XmlNodeRef root = XmlHelpers::LoadXmlFromFile(filename.toUtf8().data());
|
||||
if (!root)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Serialize(root, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CLensFlareLibrary::Serialize(XmlNodeRef& root, bool bLoading)
|
||||
{
|
||||
if (bLoading)
|
||||
{
|
||||
RemoveAllItems();
|
||||
QString name = GetName();
|
||||
root->getAttr("Name", name);
|
||||
SetName(name);
|
||||
for (int i = 0; i < root->getChildCount(); i++)
|
||||
{
|
||||
XmlNodeRef itemNode = root->getChild(i);
|
||||
CLensFlareItem* pLensFlareItem = new CLensFlareItem;
|
||||
AddItem(pLensFlareItem);
|
||||
CBaseLibraryItem::SerializeContext ctx(itemNode, bLoading);
|
||||
pLensFlareItem->Serialize(ctx);
|
||||
}
|
||||
SetModified(false);
|
||||
m_bNewLibrary = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
root->setAttr("Name", GetName().toUtf8().data());
|
||||
|
||||
for (int i = 0; i < GetItemCount(); i++)
|
||||
{
|
||||
CLensFlareItem* pItem = (CLensFlareItem*)GetItem(i);
|
||||
if(pItem)
|
||||
{
|
||||
CBaseLibraryItem::SerializeContext ctx(pItem->CreateXmlData(), bLoading);
|
||||
root->addChild(ctx.node);
|
||||
pItem->Serialize(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IOpticsElementBasePtr CLensFlareLibrary::GetOpticsOfItem(const char* szflareName)
|
||||
{
|
||||
IOpticsElementBasePtr pOptics = NULL;
|
||||
for (int i = 0; i < GetItemCount(); i++)
|
||||
{
|
||||
CLensFlareItem* pItem = (CLensFlareItem*)GetItem(i);
|
||||
|
||||
if (pItem->GetFullName() == szflareName)
|
||||
{
|
||||
pOptics = pItem->GetOptics();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pOptics;
|
||||
}
|
||||
|
||||
|
||||
void CLensFlareLibrary::OnInternalVariableChange([[maybe_unused]] IVariable* pVar)
|
||||
{
|
||||
SetModified(true);
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIBRARY_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIBRARY_H
|
||||
#pragma once
|
||||
#include "BaseLibrary.h"
|
||||
|
||||
struct IVariable;
|
||||
|
||||
class CRYEDIT_API CLensFlareLibrary
|
||||
: public CBaseLibrary
|
||||
{
|
||||
public:
|
||||
CLensFlareLibrary(IBaseLibraryManager* pManager)
|
||||
: CBaseLibrary(pManager) {};
|
||||
virtual bool Save();
|
||||
virtual bool Load(const QString& filename);
|
||||
virtual void Serialize(XmlNodeRef& node, bool bLoading);
|
||||
|
||||
IOpticsElementBasePtr GetOpticsOfItem(const char* szflareName);
|
||||
|
||||
void OnInternalVariableChange(IVariable* pVar);
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIBRARY_H
|
||||
@@ -1,225 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LensFlareLightEntityTree.h"
|
||||
|
||||
// Editor
|
||||
#include "Viewport.h"
|
||||
#include "Include/IObjectManager.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
#include "LensFlareItem.h"
|
||||
#include "LensFlareEditor.h"
|
||||
|
||||
|
||||
CLensFlareLightEntityTree::CLensFlareLightEntityTree(QWidget* pParent)
|
||||
: QTreeView(pParent)
|
||||
, m_model(new LensFlareLightEntityModel)
|
||||
{
|
||||
setHeaderHidden(true);
|
||||
|
||||
setModel(m_model.data());
|
||||
|
||||
connect(this, &QTreeView::doubleClicked, this, &CLensFlareLightEntityTree::OnTvnItemDoubleClicked);
|
||||
}
|
||||
|
||||
CLensFlareLightEntityTree::~CLensFlareLightEntityTree()
|
||||
{
|
||||
}
|
||||
|
||||
void CLensFlareLightEntityTree::OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem)
|
||||
{
|
||||
m_model->OnLensFlareChangeItem(pLensFlareItem);
|
||||
}
|
||||
|
||||
void CLensFlareLightEntityTree::OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem)
|
||||
{
|
||||
m_model->OnLensFlareDeleteItem(pLensFlareItem);
|
||||
}
|
||||
|
||||
void CLensFlareLightEntityTree::OnTvnItemDoubleClicked(const QModelIndex& index)
|
||||
{
|
||||
CEntityObject* pObject = index.data(Qt::UserRole).value<CEntityObject*>();
|
||||
|
||||
if (!qobject_cast<CEntityObject*>(pObject))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection();
|
||||
if (pSelection)
|
||||
{
|
||||
int iSelectionCount(pSelection->GetCount());
|
||||
if (iSelectionCount == 1)
|
||||
{
|
||||
if (pSelection->GetObject(0) == pObject)
|
||||
{
|
||||
CViewport* vp = GetIEditor()->GetActiveView();
|
||||
if (vp)
|
||||
{
|
||||
vp->CenterOnSelection();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GetIEditor()->GetObjectManager()->ClearSelection();
|
||||
GetIEditor()->GetObjectManager()->SelectObject(pObject);
|
||||
}
|
||||
|
||||
LensFlareLightEntityModel::LensFlareLightEntityModel(QObject* pParent)
|
||||
: QAbstractListModel(pParent)
|
||||
{
|
||||
CLensFlareEditor::GetLensFlareEditor()->RegisterLensFlareItemChangeListener(this);
|
||||
GetIEditor()->GetObjectManager()->AddObjectEventListener(this);
|
||||
}
|
||||
|
||||
LensFlareLightEntityModel::~LensFlareLightEntityModel()
|
||||
{
|
||||
CLensFlareEditor::GetLensFlareEditor()->UnregisterLensFlareItemChangeListener(this);
|
||||
GetIEditor()->GetObjectManager()->RemoveObjectEventListener(this);
|
||||
}
|
||||
|
||||
void LensFlareLightEntityModel::OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem)
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
m_pLensFlareItem = pLensFlareItem;
|
||||
m_lightEntities.clear();
|
||||
|
||||
if (m_pLensFlareItem)
|
||||
{
|
||||
std::vector<CEntityObject*> lightEntities;
|
||||
LensFlareUtil::GetLightEntityObjects(lightEntities);
|
||||
|
||||
for (int i = 0, iEntitySize(lightEntities.size()); i < iEntitySize; ++i)
|
||||
{
|
||||
AddLightEntity(lightEntities[i]);
|
||||
}
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void LensFlareLightEntityModel::OnLensFlareDeleteItem([[maybe_unused]] CLensFlareItem* pLensFlareItem)
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
m_lightEntities.clear();
|
||||
m_pLensFlareItem = NULL;
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void LensFlareLightEntityModel::OnObjectEvent(CBaseObject* pObject, int nEvent)
|
||||
{
|
||||
if (!qobject_cast<CEntityObject*>(pObject))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (nEvent)
|
||||
{
|
||||
case CBaseObject::ON_RENAME:
|
||||
case CBaseObject::ON_DELETE:
|
||||
{
|
||||
auto it = std::find(std::begin(m_lightEntities), std::end(m_lightEntities), pObject);
|
||||
if (it == std::end(m_lightEntities))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int row = std::distance(std::begin(m_lightEntities), it);
|
||||
if (nEvent == CBaseObject::ON_RENAME)
|
||||
{
|
||||
emit dataChanged(index(row, 0), index(row, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
beginRemoveRows({}, row, row);
|
||||
m_lightEntities.erase(it);
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CBaseObject::ON_ADD:
|
||||
if (AddLightEntity((CEntityObject*)pObject))
|
||||
{
|
||||
int row = m_lightEntities.size() - 1;
|
||||
beginInsertRows({}, row, row);
|
||||
endInsertRows();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool LensFlareLightEntityModel::AddLightEntity(CEntityObject* pEntity)
|
||||
{
|
||||
if (pEntity == NULL || m_pLensFlareItem == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString lensFlareName = pEntity->GetEntityPropertyString(CEntityObject::s_LensFlarePropertyName);
|
||||
if (lensFlareName.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString fullName = m_pLensFlareItem->GetFullName();
|
||||
if (fullName.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (QString::compare(lensFlareName, fullName, Qt::CaseInsensitive))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lightEntities.push_back(pEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int LensFlareLightEntityModel::rowCount(const QModelIndex&) const
|
||||
{
|
||||
return m_lightEntities.size();
|
||||
}
|
||||
|
||||
QVariant LensFlareLightEntityModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
const int row = index.row();
|
||||
|
||||
if (row < 0 || row >= m_lightEntities.size())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto pEntity = m_lightEntities[row];
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return pEntity->GetName();
|
||||
|
||||
case Qt::UserRole:
|
||||
return QVariant::fromValue<CEntityObject*>(pEntity);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
#include <LensFlareEditor/moc_LensFlareLightEntityTree.cpp>
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIGHTENTITYTREE_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIGHTENTITYTREE_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include "ILensFlareListener.h"
|
||||
|
||||
#include <QScopedPointer>
|
||||
#include <QTreeWidget>
|
||||
#include "IObjectManager.h" // for IObjectManager::EventListener
|
||||
#include "Objects/EntityObject.h"
|
||||
#endif
|
||||
|
||||
class LensFlareLightEntityModel;
|
||||
|
||||
class CLensFlareLightEntityTree
|
||||
: public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CLensFlareLightEntityTree(QWidget* pParent = nullptr);
|
||||
~CLensFlareLightEntityTree();
|
||||
|
||||
void OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem);
|
||||
void OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem);
|
||||
|
||||
protected:
|
||||
void OnTvnItemDoubleClicked(const QModelIndex& index);
|
||||
|
||||
QScopedPointer<LensFlareLightEntityModel> m_model;
|
||||
};
|
||||
|
||||
class LensFlareLightEntityModel
|
||||
: public QAbstractListModel
|
||||
, public ILensFlareChangeItemListener
|
||||
, public IObjectManager::EventListener
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LensFlareLightEntityModel(QObject* pParent = nullptr);
|
||||
~LensFlareLightEntityModel();
|
||||
|
||||
int rowCount(const QModelIndex& parent = {}) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
void OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem);
|
||||
void OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem);
|
||||
|
||||
protected:
|
||||
void OnObjectEvent(CBaseObject* pObject, int nEvent) override;
|
||||
|
||||
bool AddLightEntity(CEntityObject* pEntity);
|
||||
|
||||
std::vector<CEntityObject*> m_lightEntities;
|
||||
_smart_ptr<CLensFlareItem> m_pLensFlareItem;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(CEntityObject*)
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLARELIGHTENTITYTREE_H
|
||||
@@ -1,234 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LensFlareManager.h"
|
||||
|
||||
// AzCore
|
||||
#include <AzCore/XML/rapidxml.h>
|
||||
#include <AzCore/std/string/wildcard.h>
|
||||
|
||||
// Editor
|
||||
#include "LensFlareEditor.h"
|
||||
#include "LensFlareItem.h"
|
||||
#include "LensFlareLibrary.h"
|
||||
#include "LensFlareUtil.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CLensFlareManager implementation.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CLensFlareManager::CLensFlareManager()
|
||||
: CBaseLibraryManager()
|
||||
{
|
||||
m_bUniqNameMap = true;
|
||||
m_pLevelLibrary = (CBaseLibrary*)AddLibrary("Level", true);
|
||||
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CLensFlareManager::~CLensFlareManager()
|
||||
{
|
||||
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLensFlareManager::ClearAll()
|
||||
{
|
||||
CBaseLibraryManager::ClearAll();
|
||||
|
||||
m_pLevelLibrary = (CBaseLibrary*)AddLibrary("Level", true);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CBaseLibraryItem* CLensFlareManager::MakeNewItem()
|
||||
{
|
||||
return new CLensFlareItem;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CBaseLibrary* CLensFlareManager::MakeNewLibrary()
|
||||
{
|
||||
return new CLensFlareLibrary(this);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QString CLensFlareManager::GetRootNodeName()
|
||||
{
|
||||
return "FlareLibs";
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QString CLensFlareManager::GetLibsPath()
|
||||
{
|
||||
if (m_libsPath.isEmpty())
|
||||
{
|
||||
m_libsPath += FLARE_LIBS_PATH;
|
||||
}
|
||||
|
||||
return m_libsPath;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLensFlareManager::LoadFlareItemByName(const QString& fullItemName, IOpticsElementBasePtr pDestOptics)
|
||||
{
|
||||
if (pDestOptics == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CLensFlareItem* pLensFlareItem = (CLensFlareItem*)LoadItemByName(fullItemName);
|
||||
if (pLensFlareItem == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
LensFlareUtil::CopyOptics(pLensFlareItem->GetOptics(), pDestOptics, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLensFlareManager::Modified()
|
||||
{
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (pEditor->GetCurrentLibrary())
|
||||
{
|
||||
pEditor->GetCurrentLibrary()->SetModified(true);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IDataBaseLibrary* CLensFlareManager::LoadLibrary(const QString& filename, [[maybe_unused]] bool bReload)
|
||||
{
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
|
||||
QString fileNameWithGameFolder(filename);
|
||||
|
||||
fileNameWithGameFolder.replace('\\', '/');
|
||||
|
||||
int nGamePathLength = static_cast<int>(Path::GetEditingGameDataFolder().size());
|
||||
QString gamePathName;
|
||||
if (nGamePathLength < filename.length())
|
||||
{
|
||||
gamePathName = filename.left(nGamePathLength);
|
||||
}
|
||||
if (gamePathName != Path::GetEditingGameDataFolder().c_str())
|
||||
{
|
||||
fileNameWithGameFolder.insert(0, "/");
|
||||
fileNameWithGameFolder.insert(0, Path::GetEditingGameDataFolder().c_str());
|
||||
}
|
||||
|
||||
int nLibraryIndex(-1);
|
||||
bool bSameAsCurrentLibrary(false);
|
||||
|
||||
for (int i = 0; i < m_libs.size(); i++)
|
||||
{
|
||||
if (QString::compare(fileNameWithGameFolder, m_libs[i]->GetFilename(), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
IDataBaseLibrary* pExistingLib = m_libs[i];
|
||||
for (int j = 0; j < pExistingLib->GetItemCount(); j++)
|
||||
{
|
||||
UnregisterItem((CBaseLibraryItem*)pExistingLib->GetItem(j));
|
||||
}
|
||||
pExistingLib->RemoveAllItems();
|
||||
nLibraryIndex = i;
|
||||
if (pEditor)
|
||||
{
|
||||
bSameAsCurrentLibrary = pEditor->GetCurrentLibrary() == pExistingLib;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TSmartPtr<CBaseLibrary> pLib = MakeNewLibrary();
|
||||
if (!pLib->Load(filename))
|
||||
{
|
||||
Error(QObject::tr("Failed to Load Item Library: %1").arg(filename).toUtf8().data());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (nLibraryIndex != -1)
|
||||
{
|
||||
m_libs[nLibraryIndex] = pLib;
|
||||
if (bSameAsCurrentLibrary && pEditor)
|
||||
{
|
||||
pEditor->ResetElementTreeControl();
|
||||
pEditor->SelectLibrary(pLib, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_libs.push_back(pLib);
|
||||
}
|
||||
|
||||
pLib->SetFilename(filename);
|
||||
|
||||
return pLib;
|
||||
}
|
||||
|
||||
|
||||
bool CLensFlareManager::IsLensFlareLibraryXML(const char* fileSourceFilePath)
|
||||
{
|
||||
if ((!fileSourceFilePath) || (!AZStd::wildcard_match("*.xml", fileSourceFilePath)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
using namespace AZ::IO;
|
||||
|
||||
bool isLensFlareLibrary = false;
|
||||
|
||||
// we are forced to read the asset to discover its type since "xml" was the chosen extension.
|
||||
SystemFile::SizeType fileSize = SystemFile::Length(fileSourceFilePath);
|
||||
if (fileSize > 0)
|
||||
{
|
||||
AZStd::vector<char> buffer(fileSize + 1);
|
||||
buffer[fileSize] = 0;
|
||||
if (!AZ::IO::SystemFile::Read(fileSourceFilePath, buffer.data(), fileSize))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
AZ::rapidxml::xml_document<char>* xmlDoc = azcreate(AZ::rapidxml::xml_document<char>, (), AZ::SystemAllocator, "LensFlareLibrary Temp XML Reader");
|
||||
if (xmlDoc->parse<AZ::rapidxml::parse_no_data_nodes>(buffer.data()))
|
||||
{
|
||||
AZ::rapidxml::xml_node<char>* xmlRootNode = xmlDoc->first_node();
|
||||
if (xmlRootNode)
|
||||
{
|
||||
if (azstricmp(xmlRootNode->name(), "LensFlareLibrary") == 0)
|
||||
{
|
||||
isLensFlareLibrary = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
azdestroy(xmlDoc, AZ::SystemAllocator, AZ::rapidxml::xml_document<char>);
|
||||
}
|
||||
|
||||
return isLensFlareLibrary;
|
||||
}
|
||||
|
||||
|
||||
AzToolsFramework::AssetBrowser::SourceFileDetails CLensFlareManager::GetSourceFileDetails(const char* fullSourceFileName)
|
||||
{
|
||||
if (IsLensFlareLibraryXML(fullSourceFileName))
|
||||
{
|
||||
return AzToolsFramework::AssetBrowser::SourceFileDetails("Icons/AssetBrowser/LensFlare_16.png");
|
||||
}
|
||||
return AzToolsFramework::AssetBrowser::SourceFileDetails();
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include "BaseLibraryManager.h"
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
|
||||
|
||||
class IOpticsElementBase;
|
||||
class CLensFlareEditor;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
class CRYEDIT_API CLensFlareManager
|
||||
: public CBaseLibraryManager
|
||||
, private AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler
|
||||
|
||||
{
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
public:
|
||||
CLensFlareManager();
|
||||
virtual ~CLensFlareManager();
|
||||
|
||||
void ClearAll();
|
||||
|
||||
virtual bool LoadFlareItemByName(const QString& fullItemName, IOpticsElementBasePtr pDestOptics);
|
||||
void Modified();
|
||||
//! Path to libraries in this manager.
|
||||
QString GetLibsPath();
|
||||
IDataBaseLibrary* LoadLibrary(const QString& filename, bool bReload = false);
|
||||
|
||||
static bool IsLensFlareLibraryXML(const char* fullFilePath);
|
||||
|
||||
private:
|
||||
CBaseLibraryItem* MakeNewItem();
|
||||
CBaseLibrary* MakeNewLibrary();
|
||||
|
||||
//! Root node where this library will be saved.
|
||||
QString GetRootNodeName();
|
||||
QString m_libsPath;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// AssetBrowser::AssetBrowserInteractionNotificationBus::Handler
|
||||
AzToolsFramework::AssetBrowser::SourceFileDetails GetSourceFileDetails(const char* fullSourceFileName) override;
|
||||
virtual AZ::s32 GetPriority() const override { return 1; } // get our priority in before others.
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREMANAGER_H
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
#include "LensFlareReferenceTree.h"
|
||||
|
||||
BEGIN_MESSAGE_MAP (CLensFlareReferenceTree, CXTTreeCtrl)
|
||||
END_MESSAGE_MAP ()
|
||||
|
||||
CLensFlareReferenceTree::CLensFlareReferenceTree()
|
||||
{
|
||||
}
|
||||
|
||||
CLensFlareReferenceTree::~CLensFlareReferenceTree()
|
||||
{
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREREFERENCETREE_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREREFERENCETREE_H
|
||||
#pragma once
|
||||
|
||||
class CLensFlareReferenceTree
|
||||
: public CXTTreeCtrl
|
||||
{
|
||||
public:
|
||||
|
||||
CLensFlareReferenceTree();
|
||||
~CLensFlareReferenceTree();
|
||||
|
||||
private:
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREREFERENCETREE_H
|
||||
@@ -1,239 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LensFlareUndo.h"
|
||||
|
||||
// Editor
|
||||
#include "LensFlareEditor.h"
|
||||
#include "LensFlareItem.h"
|
||||
#include "LensFlareManager.h"
|
||||
#include "LensFlareElementTree.h"
|
||||
|
||||
|
||||
void RestoreLensFlareItem(CLensFlareItem* pLensFlareItem, IOpticsElementBasePtr pOptics, const QString& flarePathName)
|
||||
{
|
||||
pLensFlareItem->ReplaceOptics(pOptics);
|
||||
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor)
|
||||
{
|
||||
if (pOptics->GetType() == eFT_Root)
|
||||
{
|
||||
pEditor->RenameLensFlareItem(pLensFlareItem, pLensFlareItem->GetGroupName(), LensFlareUtil::GetShortName(flarePathName));
|
||||
pEditor->UpdateLensFlareItem(pLensFlareItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActivateLensFlareItem(CLensFlareItem* pLensFlareItem, bool bRestoreSelectInfo, const QString& selectedFlareItemName)
|
||||
{
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (pLensFlareItem == pEditor->GetLensFlareElementTree()->GetLensFlareItem())
|
||||
{
|
||||
pEditor->UpdateLensFlareItem(pLensFlareItem);
|
||||
if (bRestoreSelectInfo)
|
||||
{
|
||||
pEditor->SelectItemInLensFlareElementTreeByName(selectedFlareItemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CUndoLensFlareItem::CUndoLensFlareItem(CLensFlareItem* pLensFlareItem, const QString& undoDescription)
|
||||
{
|
||||
if (pLensFlareItem)
|
||||
{
|
||||
m_Undo.m_pOptics = LensFlareUtil::CreateOptics(pLensFlareItem->GetOptics());
|
||||
m_flarePathName = pLensFlareItem->GetFullName();
|
||||
m_Undo.m_bRestoreSelectInfo = false;
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor)
|
||||
{
|
||||
m_Undo.m_bRestoreSelectInfo = pEditor->GetSelectedLensFlareName(m_Undo.m_selectedFlareItemName);
|
||||
}
|
||||
m_undoDescription = undoDescription;
|
||||
}
|
||||
}
|
||||
|
||||
CUndoLensFlareItem::~CUndoLensFlareItem()
|
||||
{
|
||||
}
|
||||
|
||||
void CUndoLensFlareItem::Undo(bool bUndo)
|
||||
{
|
||||
if (bUndo)
|
||||
{
|
||||
CLensFlareItem* pLensFlareItem = (CLensFlareItem*)GetIEditor()->GetLensFlareManager()->FindItemByName(m_flarePathName);
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor && pLensFlareItem)
|
||||
{
|
||||
m_Redo.m_bRestoreSelectInfo = false;
|
||||
m_Redo.m_pOptics = LensFlareUtil::CreateOptics(pLensFlareItem->GetOptics());
|
||||
m_Redo.m_bRestoreSelectInfo = pEditor->GetSelectedLensFlareName(m_Redo.m_selectedFlareItemName);
|
||||
}
|
||||
}
|
||||
Restore(m_Undo);
|
||||
}
|
||||
|
||||
void CUndoLensFlareItem::Redo()
|
||||
{
|
||||
Restore(m_Redo);
|
||||
}
|
||||
|
||||
void CUndoLensFlareItem::Restore(const SData& data)
|
||||
{
|
||||
if (data.m_pOptics == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CLensFlareItem* pLensFlareItem = (CLensFlareItem*)GetIEditor()->GetLensFlareManager()->FindItemByName(m_flarePathName);
|
||||
if (pLensFlareItem == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
RestoreLensFlareItem(pLensFlareItem, data.m_pOptics, m_flarePathName);
|
||||
ActivateLensFlareItem(pLensFlareItem, data.m_bRestoreSelectInfo, data.m_selectedFlareItemName);
|
||||
}
|
||||
|
||||
CUndoRenameLensFlareItem::CUndoRenameLensFlareItem(const QString& oldFullName, const QString& newFullName)
|
||||
{
|
||||
m_undo.m_oldFullItemName = oldFullName;
|
||||
m_undo.m_newFullItemName = newFullName;
|
||||
}
|
||||
|
||||
void CUndoRenameLensFlareItem::Undo(bool bUndo)
|
||||
{
|
||||
if (bUndo)
|
||||
{
|
||||
m_redo.m_oldFullItemName = m_undo.m_newFullItemName;
|
||||
m_redo.m_newFullItemName = m_undo.m_oldFullItemName;
|
||||
}
|
||||
|
||||
Rename(m_undo);
|
||||
}
|
||||
|
||||
void CUndoRenameLensFlareItem::Redo()
|
||||
{
|
||||
Rename(m_redo);
|
||||
}
|
||||
|
||||
void CUndoRenameLensFlareItem::Rename(const SUndoDataStruct& data)
|
||||
{
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CLensFlareItem* pLensFlareItem = (CLensFlareItem*)GetIEditor()->GetLensFlareManager()->FindItemByName(data.m_newFullItemName);
|
||||
if (pLensFlareItem == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int nDotPos = data.m_oldFullItemName.indexOf(".");
|
||||
if (nDotPos == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString shortName(LensFlareUtil::GetShortName(data.m_oldFullItemName));
|
||||
QString groupName(LensFlareUtil::GetGroupNameFromFullName(data.m_oldFullItemName));
|
||||
pEditor->RenameLensFlareItem(pLensFlareItem, groupName, shortName);
|
||||
if (pLensFlareItem->GetOptics())
|
||||
{
|
||||
pLensFlareItem->GetOptics()->SetName(shortName.toUtf8().data());
|
||||
LensFlareUtil::UpdateOpticsName(pLensFlareItem->GetOptics());
|
||||
}
|
||||
pEditor->UpdateLensFlareItem(pLensFlareItem);
|
||||
}
|
||||
|
||||
CUndoLensFlareElementSelection::CUndoLensFlareElementSelection(CLensFlareItem* pLensFlareItem, const QString& flareTreeItemFullName, const QString& undoDescription)
|
||||
{
|
||||
if (pLensFlareItem)
|
||||
{
|
||||
m_flarePathNameForUndo = pLensFlareItem->GetFullName();
|
||||
m_flareTreeItemFullNameForUndo = flareTreeItemFullName;
|
||||
m_undoDescription = undoDescription;
|
||||
}
|
||||
}
|
||||
|
||||
void CUndoLensFlareElementSelection::Undo(bool bUndo)
|
||||
{
|
||||
if (bUndo)
|
||||
{
|
||||
m_flarePathNameForRedo = m_flarePathNameForUndo;
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor)
|
||||
{
|
||||
pEditor->GetSelectedLensFlareName(m_flareTreeItemFullNameForRedo);
|
||||
}
|
||||
}
|
||||
|
||||
CLensFlareItem* pLensFlareItem = (CLensFlareItem*)GetIEditor()->GetLensFlareManager()->FindItemByName(m_flarePathNameForUndo);
|
||||
if (pLensFlareItem == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ActivateLensFlareItem(pLensFlareItem, true, m_flareTreeItemFullNameForUndo);
|
||||
}
|
||||
|
||||
void CUndoLensFlareElementSelection::Redo()
|
||||
{
|
||||
CLensFlareItem* pLensFlareItem = (CLensFlareItem*)GetIEditor()->GetLensFlareManager()->FindItemByName(m_flarePathNameForRedo);
|
||||
if (pLensFlareItem == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ActivateLensFlareItem(pLensFlareItem, true, m_flareTreeItemFullNameForRedo);
|
||||
}
|
||||
|
||||
CUndoLensFlareItemSelectionChange::CUndoLensFlareItemSelectionChange(const QString& fullLensFlareItemName, const QString& undoDescription)
|
||||
{
|
||||
m_FullLensFlareItemNameForUndo = fullLensFlareItemName;
|
||||
m_undoDescription = undoDescription;
|
||||
}
|
||||
|
||||
void CUndoLensFlareItemSelectionChange::Undo(bool bUndo)
|
||||
{
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (bUndo)
|
||||
{
|
||||
QString currentFullName;
|
||||
pEditor->GetFullSelectedFlareItemName(currentFullName);
|
||||
m_FullLensFlareItemNameForRedo = currentFullName;
|
||||
}
|
||||
|
||||
pEditor->SelectLensFlareItem(m_FullLensFlareItemNameForUndo);
|
||||
}
|
||||
|
||||
void CUndoLensFlareItemSelectionChange::Redo()
|
||||
{
|
||||
CLensFlareEditor* pEditor = CLensFlareEditor::GetLensFlareEditor();
|
||||
if (pEditor == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pEditor->SelectLensFlareItem(m_FullLensFlareItemNameForRedo);
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREUNDO_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREUNDO_H
|
||||
#pragma once
|
||||
|
||||
#include "Undo/IUndoObject.h"
|
||||
|
||||
class CLensFlareItem;
|
||||
|
||||
class CUndoLensFlareItem
|
||||
: public IUndoObject
|
||||
{
|
||||
public:
|
||||
CUndoLensFlareItem(CLensFlareItem* pGroupItem, const QString& undoDescription = "Undo Lens Flare Tree");
|
||||
~CUndoLensFlareItem();
|
||||
|
||||
protected:
|
||||
int GetSize()
|
||||
{
|
||||
return sizeof(*this);
|
||||
}
|
||||
QString GetDescription() { return m_undoDescription; };
|
||||
void Undo(bool bUndo);
|
||||
void Redo();
|
||||
|
||||
private:
|
||||
|
||||
QString m_undoDescription;
|
||||
|
||||
struct SData
|
||||
{
|
||||
SData()
|
||||
{
|
||||
m_pOptics = NULL;
|
||||
}
|
||||
|
||||
QString m_selectedFlareItemName;
|
||||
bool m_bRestoreSelectInfo;
|
||||
IOpticsElementBasePtr m_pOptics;
|
||||
};
|
||||
|
||||
QString m_flarePathName;
|
||||
SData m_Undo;
|
||||
SData m_Redo;
|
||||
|
||||
void Restore(const SData& data);
|
||||
};
|
||||
|
||||
class CUndoRenameLensFlareItem
|
||||
: public IUndoObject
|
||||
{
|
||||
public:
|
||||
|
||||
CUndoRenameLensFlareItem(const QString& oldFullName, const QString& newFullName);
|
||||
|
||||
protected:
|
||||
|
||||
int GetSize()
|
||||
{
|
||||
return sizeof(*this);
|
||||
}
|
||||
QString GetDescription() { return m_undoDescription; };
|
||||
void Undo(bool bUndo);
|
||||
void Redo();
|
||||
|
||||
private:
|
||||
|
||||
QString m_undoDescription;
|
||||
|
||||
struct SUndoDataStruct
|
||||
{
|
||||
QString m_oldFullItemName;
|
||||
QString m_newFullItemName;
|
||||
};
|
||||
|
||||
void Rename(const SUndoDataStruct& data);
|
||||
|
||||
SUndoDataStruct m_undo;
|
||||
SUndoDataStruct m_redo;
|
||||
};
|
||||
|
||||
class CUndoLensFlareElementSelection
|
||||
: public IUndoObject
|
||||
{
|
||||
public:
|
||||
CUndoLensFlareElementSelection(CLensFlareItem* pLensFlareItem, const QString& flareTreeItemFullName, const QString& undoDescription = "Undo Lens Flare Element Tree");
|
||||
~CUndoLensFlareElementSelection(){}
|
||||
|
||||
protected:
|
||||
int GetSize()
|
||||
{
|
||||
return sizeof(*this);
|
||||
}
|
||||
QString GetDescription() { return m_undoDescription; };
|
||||
void Undo(bool bUndo);
|
||||
void Redo();
|
||||
|
||||
private:
|
||||
|
||||
QString m_undoDescription;
|
||||
|
||||
QString m_flarePathNameForUndo;
|
||||
QString m_flareTreeItemFullNameForUndo;
|
||||
|
||||
QString m_flarePathNameForRedo;
|
||||
QString m_flareTreeItemFullNameForRedo;
|
||||
};
|
||||
|
||||
class CUndoLensFlareItemSelectionChange
|
||||
: public IUndoObject
|
||||
{
|
||||
public:
|
||||
CUndoLensFlareItemSelectionChange(const QString& fullLensFlareItemName, const QString& undoDescription = "Undo Lens Flare element selection");
|
||||
~CUndoLensFlareItemSelectionChange(){}
|
||||
|
||||
protected:
|
||||
int GetSize()
|
||||
{
|
||||
return sizeof(*this);
|
||||
}
|
||||
QString GetDescription() { return m_undoDescription; };
|
||||
|
||||
void Undo(bool bUndo);
|
||||
void Redo();
|
||||
|
||||
private:
|
||||
QString m_undoDescription;
|
||||
QString m_FullLensFlareItemNameForUndo;
|
||||
QString m_FullLensFlareItemNameForRedo;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREUNDO_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,363 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREUTIL_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREUTIL_H
|
||||
#pragma once
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QModelIndex>
|
||||
|
||||
#include "Util/Variable.h"
|
||||
|
||||
#include "IFlares.h"
|
||||
class CEntityObject;
|
||||
|
||||
class QTreeView;
|
||||
|
||||
#define LENSFLARE_ELEMENT_TREE "LensFlareElementTree"
|
||||
#define LENSFLARE_ITEM_TREE "LensFlareItemTree"
|
||||
#define FLARECLIPBOARDTYPE_COPY "Copy"
|
||||
#define FLARECLIPBOARDTYPE_CUT "Cut"
|
||||
|
||||
namespace LensFlareUtil
|
||||
{
|
||||
inline bool IsElement(EFlareType type)
|
||||
{
|
||||
return type != eFT__Base__ && type != eFT_Root && type != eFT_Group;
|
||||
}
|
||||
inline bool IsGroup(EFlareType type)
|
||||
{
|
||||
return type == eFT_Root || type == eFT_Group;
|
||||
}
|
||||
inline bool IsValidFlare(EFlareType type)
|
||||
{
|
||||
return type >= eFT__Base__ && type < eFT_Max;
|
||||
}
|
||||
|
||||
inline void AddVariable(CVariableBase& varArray, CVariableBase& var, const char* varName, const char* humanVarName, const char* description, char dataType = IVariable::DT_SIMPLE)
|
||||
{
|
||||
if (varName)
|
||||
{
|
||||
var.SetName(varName);
|
||||
}
|
||||
if (humanVarName)
|
||||
{
|
||||
var.SetHumanName(humanVarName);
|
||||
}
|
||||
if (description)
|
||||
{
|
||||
var.SetDescription(description);
|
||||
}
|
||||
var.SetDataType(dataType);
|
||||
varArray.AddVariable(&var);
|
||||
}
|
||||
|
||||
inline void AddVariable(CVarBlock* vars, CVariableBase& var, const char* varName, const char* humanVarName, const char* description, unsigned char dataType = IVariable::DT_SIMPLE)
|
||||
{
|
||||
if (varName)
|
||||
{
|
||||
var.SetName(varName);
|
||||
}
|
||||
if (humanVarName)
|
||||
{
|
||||
var.SetHumanName(humanVarName);
|
||||
}
|
||||
if (description)
|
||||
{
|
||||
var.SetDescription(description);
|
||||
}
|
||||
var.SetDataType(dataType);
|
||||
vars->AddVariable(&var);
|
||||
}
|
||||
|
||||
inline bool GetFlareType(const QString& typeName, EFlareType& outType)
|
||||
{
|
||||
FlareInfoArray::Props array = FlareInfoArray::Get();
|
||||
for (size_t i = 0; i < array.size; ++i)
|
||||
{
|
||||
if (typeName == array.p[i].name)
|
||||
{
|
||||
outType = array.p[i].type;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool GetFlareTypeName(QString& outTypeName, IOpticsElementBasePtr pOptics)
|
||||
{
|
||||
if (pOptics == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const FlareInfoArray::Props array = FlareInfoArray::Get();
|
||||
for (size_t i = 0; i < array.size; ++i)
|
||||
{
|
||||
if (array.p[i].type == pOptics->GetType())
|
||||
{
|
||||
outTypeName = array.p[i].name;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline QString GetShortName(const QString& name)
|
||||
{
|
||||
int nPos = name.lastIndexOf('.');
|
||||
if (nPos == -1)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
return name.right(name.length() - nPos - 1);
|
||||
}
|
||||
|
||||
inline QString GetGroupNameFromName(const QString& name)
|
||||
{
|
||||
int nPos = name.lastIndexOf('.');
|
||||
if (nPos == -1)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
return name.left(nPos);
|
||||
}
|
||||
|
||||
inline QString GetGroupNameFromFullName(const QString& fullItemName)
|
||||
{
|
||||
int nLastDotPos = fullItemName.lastIndexOf('.');
|
||||
if (nLastDotPos == -1)
|
||||
{
|
||||
return fullItemName;
|
||||
}
|
||||
|
||||
QString name = GetGroupNameFromName(fullItemName);
|
||||
|
||||
int nFirstDotPos = name.indexOf('.');
|
||||
if (nFirstDotPos == -1)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
return name.right(name.length() - nFirstDotPos - 1);
|
||||
}
|
||||
|
||||
inline bool HaveParameterLowBoundary(const QString& paramName)
|
||||
{
|
||||
if (!QString::compare(paramName, "Noiseseed", Qt::CaseInsensitive) || !QString::compare(paramName, "translation", Qt::CaseInsensitive) || !QString::compare(paramName, "position", Qt::CaseInsensitive) || !QString::compare(paramName, "rotation", Qt::CaseInsensitive))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline int MakeFuncKey(int nGroupIndex, int nVarIndex)
|
||||
{
|
||||
return (nGroupIndex << 16) | nVarIndex;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void BoundaryProcess(T& fValue)
|
||||
{
|
||||
if (fValue < 0)
|
||||
{
|
||||
fValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline void BoundaryProcess(Vec2& v)
|
||||
{
|
||||
if (v.x < 0)
|
||||
{
|
||||
v.x = 0;
|
||||
}
|
||||
if (v.y < 0)
|
||||
{
|
||||
v.y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline void BoundaryProcess(Vec3& v)
|
||||
{
|
||||
if (v.x < 0)
|
||||
{
|
||||
v.x = 0;
|
||||
}
|
||||
if (v.y < 0)
|
||||
{
|
||||
v.y = 0;
|
||||
}
|
||||
if (v.z < 0)
|
||||
{
|
||||
v.z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline void BoundaryProcess(Vec4& v)
|
||||
{
|
||||
if (v.x < 0)
|
||||
{
|
||||
v.x = 0;
|
||||
}
|
||||
if (v.y < 0)
|
||||
{
|
||||
v.y = 0;
|
||||
}
|
||||
if (v.z < 0)
|
||||
{
|
||||
v.z = 0;
|
||||
}
|
||||
if (v.w < 0)
|
||||
{
|
||||
v.w = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool ExtractVec4FromString(const string& buffer, Vec4& outVec4)
|
||||
{
|
||||
int nCount(0);
|
||||
string copiedBuffer(buffer);
|
||||
int commaPos(0);
|
||||
while (nCount < 4 || commaPos != -1)
|
||||
{
|
||||
commaPos = copiedBuffer.find(",");
|
||||
string strV;
|
||||
if (commaPos == -1)
|
||||
{
|
||||
strV = copiedBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
strV = copiedBuffer.Left(commaPos);
|
||||
strV += ",";
|
||||
}
|
||||
copiedBuffer.replace(0, commaPos + 1, "");
|
||||
outVec4[nCount++] = (float)atof(strV.c_str());
|
||||
}
|
||||
return nCount == 4;
|
||||
}
|
||||
|
||||
void FillParams(XmlNodeRef& paramNode, IOpticsElementBase* pOptics);
|
||||
|
||||
inline bool FindGroup(const char* groupName, IOpticsElementBase* pOptics, int& nOutGroupIndex)
|
||||
{
|
||||
if (groupName == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
AZStd::vector<FuncVariableGroup> groupArray = pOptics->GetEditorParamGroups();
|
||||
for (int i = 0, iCount(groupArray.size()); i < iCount; ++i)
|
||||
{
|
||||
if (!_stricmp(groupArray[i].GetName(), groupName))
|
||||
{
|
||||
nOutGroupIndex = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct SClipboardData
|
||||
{
|
||||
SClipboardData(){}
|
||||
~SClipboardData(){}
|
||||
SClipboardData(const QString& from, const QString& lensFlareFullPath, const QString& lensOpticsPath)
|
||||
: m_From(from)
|
||||
, m_LensFlareFullPath(lensFlareFullPath)
|
||||
, m_LensOpticsPath(lensOpticsPath)
|
||||
{
|
||||
}
|
||||
|
||||
void FillXmlNode(XmlNodeRef node)
|
||||
{
|
||||
if (node == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
node->setAttr("From", m_From.toUtf8().data());
|
||||
node->setAttr("FlareFullPath", m_LensFlareFullPath.toUtf8().data());
|
||||
node->setAttr("OpticsPath", m_LensOpticsPath.toUtf8().data());
|
||||
}
|
||||
|
||||
void FillThisFromXmlNode(XmlNodeRef node)
|
||||
{
|
||||
if (node == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
node->getAttr("From", m_From);
|
||||
node->getAttr("FlareFullPath", m_LensFlareFullPath);
|
||||
node->getAttr("OpticsPath", m_LensOpticsPath);
|
||||
}
|
||||
|
||||
QString m_From;
|
||||
QString m_LensFlareFullPath;
|
||||
QString m_LensOpticsPath;
|
||||
};
|
||||
|
||||
struct SDragAndDropInfo
|
||||
{
|
||||
SDragAndDropInfo()
|
||||
{
|
||||
m_XMLContents = NULL;
|
||||
m_bDragging = false;
|
||||
}
|
||||
~SDragAndDropInfo()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
void Reset()
|
||||
{
|
||||
m_XMLContents = NULL;
|
||||
m_bDragging = false;
|
||||
}
|
||||
bool m_bDragging;
|
||||
XmlNodeRef m_XMLContents;
|
||||
};
|
||||
|
||||
inline SDragAndDropInfo& GetDragDropInfo()
|
||||
{
|
||||
static SDragAndDropInfo dragDropInfo;
|
||||
return dragDropInfo;
|
||||
}
|
||||
|
||||
int FindOpticsIndexUnderParentOptics(IOpticsElementBasePtr pOptics, IOpticsElementBasePtr pParentOptics);
|
||||
bool IsPointInWindow(const QWidget* pWindow, const QPoint& screenPos);
|
||||
QModelIndex GetTreeItemByHitTest(QTreeView& treeCtrl);
|
||||
QPoint GetDragCursorPos(QWidget* pWnd, const QPoint& point);
|
||||
void GetExpandedItemNames(CBaseLibraryItem* item, const QString& groupName, const QString& itemName, QString& outNameWithGroup, QString& outFullName);
|
||||
void GetSelectedLightEntities(std::vector<CEntityObject*>& outLightEntities);
|
||||
void GetLightEntityObjects(std::vector<CEntityObject*>& outEntityLights);
|
||||
IFuncVariable* GetFuncVariable(IOpticsElementBasePtr pOptics, int nFuncKey);
|
||||
QString ReplaceLastName(const QString& fullName, const QString& shortName);
|
||||
void UpdateOpticsName(IOpticsElementBasePtr pOptics);
|
||||
XmlNodeRef CreateXMLFromClipboardData(const QString& type, const QString& groupName, bool bPasteAtSameLevel, std::vector<SClipboardData>& dataList);
|
||||
void UpdateClipboard(const QString& type, const QString& groupName, bool bPasteAtSameLevel, std::vector<SClipboardData>& dataList);
|
||||
void ChangeOpticsRootName(IOpticsElementBasePtr pOptics, const QString& newRootName);
|
||||
void RemoveOptics(IOpticsElementBasePtr pOptics);
|
||||
IOpticsElementBasePtr FindOptics(IOpticsElementBasePtr pStartOptics, const QString& name);
|
||||
CEntityObject* GetSelectedLightEntity();
|
||||
IOpticsElementBasePtr GetSelectedLightOptics();
|
||||
IOpticsElementBasePtr CreateOptics(const XmlNodeRef& xmlNode);
|
||||
IOpticsElementBasePtr CreateOptics(IOpticsElementBasePtr pOptics, bool bForceTypeToGroup = false);
|
||||
bool FillOpticsFromXML(IOpticsElementBasePtr pOptics, const XmlNodeRef& xmlNode);
|
||||
bool CreateXmlData(IOpticsElementBasePtr pOptics, XmlNodeRef& pOutNode);
|
||||
void SetVariablesTemplateFromOptics(IOpticsElementBasePtr pOptics, CVarBlockPtr& pRootVar, std::vector<IVariable::OnSetCallback*>& funcs);
|
||||
void SetVariablesTemplateFromOptics(IOpticsElementBasePtr pOptics, CVarBlockPtr& pRootVar);
|
||||
void CopyOptics(IOpticsElementBasePtr pSrcOptics, IOpticsElementBasePtr pDestOptics, bool bReculsiveCopy = true);
|
||||
void OutputOpticsDebug(IOpticsElementBasePtr pOptics);
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREUTIL_H
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LensFlareView.h"
|
||||
|
||||
// Editor
|
||||
#include "LensFlareItem.h"
|
||||
#include "LensFlareEditor.h"
|
||||
#include "Objects/EntityObject.h"
|
||||
#include "Material/MaterialManager.h"
|
||||
|
||||
|
||||
CLensFlareView::CLensFlareView(QWidget* parent, Qt::WindowFlags f)
|
||||
: CPreviewModelCtrl(parent, f)
|
||||
{
|
||||
InitDialog();
|
||||
}
|
||||
|
||||
CLensFlareView::~CLensFlareView()
|
||||
{
|
||||
CLensFlareEditor::GetLensFlareEditor()->UnregisterLensFlareItemChangeListener(this);
|
||||
}
|
||||
|
||||
void CLensFlareView::InitDialog()
|
||||
{
|
||||
CLensFlareEditor::GetLensFlareEditor()->RegisterLensFlareItemChangeListener(this);
|
||||
|
||||
SetClearColor(ColorF(0, 0, 0, 0));
|
||||
SetGrid(true);
|
||||
SetAxis(true);
|
||||
EnableUpdate(true);
|
||||
m_pLensFlareMaterial = GetIEditor()->GetMaterialManager()->LoadMaterial(CEntityObject::s_LensFlareMaterialName);
|
||||
m_InitCameraPos = m_camera.GetPosition();
|
||||
}
|
||||
|
||||
void CLensFlareView::RenderObject(_smart_ptr<IMaterial> pMaterial, [[maybe_unused]] SRenderingPassInfo& passInfo)
|
||||
{
|
||||
if (m_pLensFlareItem)
|
||||
{
|
||||
IOpticsElementBasePtr pOptics = m_pLensFlareItem->GetOptics();
|
||||
if (pOptics && m_pLensFlareMaterial)
|
||||
{
|
||||
_smart_ptr<IMaterial> pMaterial = m_pLensFlareMaterial->GetMatInfo();
|
||||
if (pMaterial)
|
||||
{
|
||||
m_pRenderer->ForceUpdateGlobalShaderParameters();
|
||||
m_pRenderer->SetViewport(1, 1, m_pRenderer->GetWidth(), m_pRenderer->GetHeight());
|
||||
SShaderItem& shaderItem = pMaterial->GetShaderItem();
|
||||
SLensFlareRenderParam param;
|
||||
param.pCamera = &m_camera;
|
||||
param.pShader = shaderItem.m_pShader;
|
||||
pOptics->Render(¶m, Vec3(0, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLensFlareView::OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem)
|
||||
{
|
||||
if (m_pLensFlareItem != pLensFlareItem)
|
||||
{
|
||||
m_pLensFlareItem = pLensFlareItem;
|
||||
Update(true);
|
||||
m_bHaveAnythingToRender = m_pLensFlareItem != NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CLensFlareView::OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem)
|
||||
{
|
||||
if (m_pLensFlareItem == pLensFlareItem)
|
||||
{
|
||||
m_pLensFlareItem = NULL;
|
||||
Update();
|
||||
m_bHaveAnythingToRender = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CLensFlareView::OnInternalVariableChange([[maybe_unused]] IVariable* pVar)
|
||||
{
|
||||
Update();
|
||||
}
|
||||
|
||||
void CLensFlareView::OnLensFlareChangeElement([[maybe_unused]] CLensFlareElement* pLensFlareElement)
|
||||
{
|
||||
Update();
|
||||
}
|
||||
|
||||
void CLensFlareView::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case eNotify_OnCloseScene:
|
||||
ReleaseObject();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREVIEW_H
|
||||
#define CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREVIEW_H
|
||||
#pragma once
|
||||
|
||||
#include "ILensFlareListener.h"
|
||||
#include "Controls/PreviewModelCtrl.h"
|
||||
|
||||
class CLensFlareView
|
||||
: public CPreviewModelCtrl
|
||||
, public ILensFlareChangeItemListener
|
||||
, public ILensFlareChangeElementListener
|
||||
{
|
||||
public:
|
||||
explicit CLensFlareView(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
~CLensFlareView();
|
||||
|
||||
void OnInternalVariableChange(IVariable* pVar);
|
||||
void OnEditorNotifyEvent(EEditorNotifyEvent event);
|
||||
|
||||
protected:
|
||||
|
||||
void InitDialog();
|
||||
void ProcessKeys(){}
|
||||
void RenderObject(_smart_ptr<IMaterial> pMaterial, SRenderingPassInfo& passInfo);
|
||||
|
||||
void OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem);
|
||||
void OnLensFlareDeleteItem(CLensFlareItem* pLensFlareItem);
|
||||
void OnLensFlareChangeElement(CLensFlareElement* pLensFlareElement);
|
||||
|
||||
private:
|
||||
|
||||
QPoint m_prevPoint;
|
||||
Vec3 m_InitCameraPos;
|
||||
|
||||
_smart_ptr<CMaterial> m_pLensFlareMaterial;
|
||||
_smart_ptr<CLensFlareItem> m_pLensFlareItem;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREVIEW_H
|
||||
@@ -96,7 +96,6 @@ public:
|
||||
MOCK_METHOD0(GetIEditorMaterialManager, IEditorMaterialManager* ());
|
||||
MOCK_METHOD0(GetIconManager, IIconManager* ());
|
||||
MOCK_METHOD0(GetMusicManager, CMusicManager* ());
|
||||
MOCK_METHOD0(GetLensFlareManager, CLensFlareManager* ());
|
||||
MOCK_METHOD2(GetTerrainElevation, float(float , float ));
|
||||
MOCK_METHOD0(GetVegetationMap, class CVegetationMap* ());
|
||||
MOCK_METHOD0(GetEditorQtApplication, Editor::EditorQtApplication* ());
|
||||
|
||||
@@ -44,7 +44,6 @@ namespace LyViewPane
|
||||
static const char* const TerrainTool = "Terrain Tool";
|
||||
static const char* const TerrainTextureLayers = "Terrain Texture Layers";
|
||||
static const char* const ParticleEditor = "Particle Editor";
|
||||
static const char* const LensFlareEditor = "Lens Flare Editor";
|
||||
static const char* const TimeOfDayEditor = "Time Of Day";
|
||||
static const char* const AudioControlsEditor = "Audio Controls Editor";
|
||||
static const char* const SubstanceEditor = "Substance Editor";
|
||||
|
||||
@@ -91,7 +91,6 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
#include "TrackView/TrackViewDialog.h"
|
||||
#include "ErrorReportDialog.h"
|
||||
#include "LensFlareEditor/LensFlareEditor.h"
|
||||
#include "TimeOfDayDialog.h"
|
||||
|
||||
#include "Dialogs/PythonScriptsDialog.h"
|
||||
@@ -1657,7 +1656,6 @@ void MainWindow::RegisterStdViewClasses()
|
||||
|
||||
if (!AZ::Interface<AzFramework::AtomActiveInterface>::Get())
|
||||
{
|
||||
CLensFlareEditor::RegisterViewClass();
|
||||
CTimeOfDayDialog::RegisterViewClass();
|
||||
}
|
||||
#ifdef ThumbnailDemo
|
||||
|
||||
@@ -29,18 +29,11 @@
|
||||
#include "Include/IObjectManager.h"
|
||||
#include "Objects/ObjectManager.h"
|
||||
#include "ViewManager.h"
|
||||
#include "LensFlareEditor/LensFlareManager.h"
|
||||
#include "LensFlareEditor/LensFlareUtil.h"
|
||||
#include "LensFlareEditor/LensFlareLibrary.h"
|
||||
#include "AnimationContext.h"
|
||||
#include "HitContext.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
|
||||
|
||||
const char* CEntityObject::s_LensFlarePropertyName("flare_Flare");
|
||||
const char* CEntityObject::s_LensFlareMaterialName("EngineAssets/Materials/lens_optics");
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Undo Entity Link
|
||||
class CUndoEntityLink
|
||||
@@ -1976,60 +1969,6 @@ IOpticsElementBasePtr CEntityObject::GetOpticsElement()
|
||||
return pLight->GetLensOpticsElement();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::SetOpticsElement(IOpticsElementBase* pOptics)
|
||||
{
|
||||
CDLight* pLight = GetLightProperty();
|
||||
if (pLight == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pLight->SetLensOpticsElement(pOptics);
|
||||
if (GetEntityPropertyBool("bFlareEnable") && pOptics)
|
||||
{
|
||||
CBaseObject::SetMaterial(s_LensFlareMaterialName);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMaterial(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::ApplyOptics(const QString& opticsFullName, IOpticsElementBasePtr pOptics)
|
||||
{
|
||||
if (pOptics == NULL)
|
||||
{
|
||||
CDLight* pLight = GetLightProperty();
|
||||
if (pLight)
|
||||
{
|
||||
pLight->SetLensOpticsElement(NULL);
|
||||
}
|
||||
SetFlareName("");
|
||||
SetMaterial(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
int nOpticsIndex(0);
|
||||
if (!gEnv->pOpticsManager->Load(opticsFullName.toUtf8().data(), nOpticsIndex))
|
||||
{
|
||||
IOpticsElementBasePtr pNewOptics = gEnv->pOpticsManager->Create(eFT_Root);
|
||||
if (!gEnv->pOpticsManager->AddOptics(pNewOptics, opticsFullName.toUtf8().data(), nOpticsIndex))
|
||||
{
|
||||
CDLight* pLight = GetLightProperty();
|
||||
if (pLight)
|
||||
{
|
||||
pLight->SetLensOpticsElement(NULL);
|
||||
SetMaterial(NULL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
LensFlareUtil::CopyOptics(pOptics, pNewOptics);
|
||||
}
|
||||
SetFlareName(opticsFullName);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::SetOpticsName(const QString& opticsFullName)
|
||||
{
|
||||
@@ -2040,19 +1979,8 @@ void CEntityObject::SetOpticsName(const QString& opticsFullName)
|
||||
{
|
||||
pLight->SetLensOpticsElement(NULL);
|
||||
}
|
||||
SetFlareName("");
|
||||
SetMaterial(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetOpticsElement())
|
||||
{
|
||||
if (gEnv->pOpticsManager->Rename(GetOpticsElement()->GetName(), opticsFullName.toUtf8().data()))
|
||||
{
|
||||
SetFlareName(opticsFullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -2080,27 +2008,6 @@ CDLight* CEntityObject::GetLightProperty() const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CEntityObject::GetValidFlareName(QString& outFlareName) const
|
||||
{
|
||||
IVariable* pFlareVar(m_pProperties->FindVariable(s_LensFlarePropertyName));
|
||||
if (!pFlareVar)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString flareName;
|
||||
pFlareVar->Get(flareName);
|
||||
if (flareName.isEmpty() || flareName == "@root")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
outFlareName = flareName;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::PreInitLightProperty()
|
||||
{
|
||||
@@ -2108,42 +2015,6 @@ void CEntityObject::PreInitLightProperty()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString flareFullName;
|
||||
if (GetValidFlareName(flareFullName))
|
||||
{
|
||||
bool bEnableOptics = GetEntityPropertyBool("bFlareEnable");
|
||||
if (bEnableOptics)
|
||||
{
|
||||
CLensFlareManager* pLensManager = GetIEditor()->GetLensFlareManager();
|
||||
CLensFlareLibrary* pLevelLib = (CLensFlareLibrary*)pLensManager->GetLevelLibrary();
|
||||
IOpticsElementBasePtr pLevelOptics = pLevelLib->GetOpticsOfItem(flareFullName.toUtf8().data());
|
||||
if (pLevelLib && pLevelOptics)
|
||||
{
|
||||
int nOpticsIndex(0);
|
||||
IOpticsElementBasePtr pNewOptics = GetOpticsElement();
|
||||
if (pNewOptics == NULL)
|
||||
{
|
||||
pNewOptics = gEnv->pOpticsManager->Create(eFT_Root);
|
||||
}
|
||||
|
||||
if (gEnv->pOpticsManager->AddOptics(pNewOptics, flareFullName.toUtf8().data(), nOpticsIndex))
|
||||
{
|
||||
LensFlareUtil::CopyOptics(pLevelOptics, pNewOptics);
|
||||
SetOpticsElement(pNewOptics);
|
||||
}
|
||||
else
|
||||
{
|
||||
CDLight* pLight = GetLightProperty();
|
||||
if (pLight)
|
||||
{
|
||||
pLight->SetLensOpticsElement(NULL);
|
||||
SetMaterial(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -2153,26 +2024,6 @@ void CEntityObject::UpdateLightProperty()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString flareName;
|
||||
if (GetValidFlareName(flareName))
|
||||
{
|
||||
IOpticsElementBasePtr pOptics = GetOpticsElement();
|
||||
if (pOptics == NULL)
|
||||
{
|
||||
pOptics = gEnv->pOpticsManager->Create(eFT_Root);
|
||||
}
|
||||
bool bEnableOptics = GetEntityPropertyBool("bFlareEnable");
|
||||
if (bEnableOptics && GetIEditor()->GetLensFlareManager()->LoadFlareItemByName(flareName, pOptics))
|
||||
{
|
||||
pOptics->SetName(flareName.toUtf8().data());
|
||||
SetOpticsElement(pOptics);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetOpticsElement(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -221,10 +221,7 @@ public:
|
||||
|
||||
IVariable* GetLightVariable(const char* name) const;
|
||||
IOpticsElementBasePtr GetOpticsElement();
|
||||
void SetOpticsElement(IOpticsElementBase* pOptics);
|
||||
void ApplyOptics(const QString& opticsFullName, IOpticsElementBasePtr pOptics);
|
||||
void SetOpticsName(const QString& opticsFullName);
|
||||
bool GetValidFlareName(QString& outFlareName) const;
|
||||
|
||||
void PreInitLightProperty();
|
||||
void UpdateLightProperty();
|
||||
@@ -236,9 +233,6 @@ public:
|
||||
|
||||
static void StoreUndoEntityLink(CSelectionGroup* pGroup);
|
||||
|
||||
static const char* s_LensFlarePropertyName;
|
||||
static const char* s_LensFlareMaterialName;
|
||||
|
||||
void RegisterListener(IEntityObjectListener* pListener);
|
||||
void UnregisterListener(IEntityObjectListener* pListener);
|
||||
|
||||
@@ -322,11 +316,6 @@ protected:
|
||||
void AdjustLightProperties(CVarBlockPtr& properties, const char* pSubBlock);
|
||||
IVariable* FindVariableInSubBlock(CVarBlockPtr& properties, IVariable* pSubBlockVar, const char* pVarName);
|
||||
|
||||
void SetFlareName(const QString& name)
|
||||
{
|
||||
SetEntityPropertyString(s_LensFlarePropertyName, name);
|
||||
}
|
||||
|
||||
unsigned int m_bLoadFailed : 1;
|
||||
unsigned int m_bCalcPhysics : 1;
|
||||
unsigned int m_bDisplayBBox : 1;
|
||||
|
||||
@@ -9,13 +9,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
ly_add_bundle_resources(
|
||||
TARGET Editor
|
||||
FILES
|
||||
${CMAKE_SOURCE_DIR}/Code/Tools/RC/Config/rc/xmlfilter.txt
|
||||
${CMAKE_SOURCE_DIR}/Code/Tools/RC/Config/rc/rc.ini
|
||||
)
|
||||
|
||||
# Set resources directory for app icons
|
||||
target_sources(Editor PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Images.xcassets)
|
||||
set_target_properties(Editor PROPERTIES
|
||||
|
||||
@@ -4,6 +4,5 @@
|
||||
<file alias="Assets/Editor/Style/EditorPreferencesDialog.qss">EditorPreferencesDialog.qss</file>
|
||||
<file alias="Assets/Editor/Style/LayoutConfigDialog.qss">LayoutConfigDialog.qss</file>
|
||||
<file alias="Assets/Editor/Style/GraphicsSettingsDialog.qss">GraphicsSettingsDialog.qss</file>
|
||||
<file alias="Assets/Editor/Style/LensFlareEditor.qss">LensFlareEditor.qss</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -27,11 +27,6 @@
|
||||
// ComponentEntityEditorPlugin
|
||||
#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h"
|
||||
|
||||
// LmbrCentral
|
||||
#include <LmbrCentral/Rendering/MeshComponentBus.h>
|
||||
#include <LmbrCentral/Rendering/GeomCacheComponentBus.h>
|
||||
|
||||
|
||||
static const float kEnoughFarDistance(5000.0f);
|
||||
|
||||
CSurfaceInfoPicker::CSurfaceInfoPicker()
|
||||
@@ -185,19 +180,6 @@ void CSurfaceInfoPicker::FindNearestInfoFromEntities(
|
||||
AZ::EntityId id;
|
||||
AzToolsFramework::ComponentEntityObjectRequestBus::EventResult(id, entityObject, &AzToolsFramework::ComponentEntityObjectRequestBus::Events::GetAssociatedEntityId);
|
||||
|
||||
AZ::EBusAggregateResults<IStatObj*> statObjs;
|
||||
LmbrCentral::LegacyMeshComponentRequestBus::EventResult(statObjs, id, &LmbrCentral::LegacyMeshComponentRequestBus::Events::GetStatObj);
|
||||
|
||||
// If the entity has a MeshComponent, it will hit here
|
||||
for (IStatObj* statObj : statObjs.values)
|
||||
{
|
||||
hit = RayIntersection(vWorldRaySrc, vWorldRayDir, nullptr, statObj, object->GetWorldTM(), outHitInfo, &statObjDefaultMaterial);
|
||||
if (hit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If the entity has an ActorComponent or another component that overrides RenderNodeRequestBus, it will hit here
|
||||
if (!hit)
|
||||
{
|
||||
@@ -237,14 +219,6 @@ void CSurfaceInfoPicker::FindNearestInfoFromEntities(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the entity has a GeometryCacheComponent it will hit here
|
||||
if (!hit)
|
||||
{
|
||||
IGeomCacheRenderNode* geomCacheRenderNode = nullptr;
|
||||
LmbrCentral::GeometryCacheComponentRequestBus::EventResult(geomCacheRenderNode, id, &LmbrCentral::GeometryCacheComponentRequestBus::Events::GetGeomCacheRenderNode);
|
||||
hit = RayIntersection_IGeomCacheRenderNode(vWorldRaySrc, vWorldRayDir, geomCacheRenderNode, &pickedMaterial, object->GetWorldTM(), outHitInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (hit)
|
||||
|
||||
@@ -163,7 +163,7 @@ struct IVariable
|
||||
DT_LIGHT_ANIMATION, // Light Animation Node in the global Light Animation Set
|
||||
DT_PARTICLE_EFFECT,
|
||||
DT_GEOM_CACHE, // Geometry cache
|
||||
DT_FLARE,
|
||||
DT_DEPRECATED, // formerly DT_FLARE
|
||||
DT_AUDIO_TRIGGER,
|
||||
DT_AUDIO_SWITCH,
|
||||
DT_AUDIO_SWITCH_STATE,
|
||||
|
||||
@@ -58,7 +58,6 @@ namespace Prop
|
||||
{ IVariable::DT_USERITEMCB, "User", ePropertyUser, -1 },
|
||||
{ IVariable::DT_SEQUENCE_ID, "SequenceId", ePropertySequenceId, -1 },
|
||||
{ IVariable::DT_LIGHT_ANIMATION, "LightAnimation", ePropertyLightAnimation, -1 },
|
||||
{ IVariable::DT_FLARE, "Flare", ePropertyFlare, 7 },
|
||||
{ IVariable::DT_PARTICLE_EFFECT, "ParticleEffect", ePropertyParticleName, 3 },
|
||||
{ IVariable::DT_GEOM_CACHE, "Geometry Cache", ePropertyGeomCache, 5 },
|
||||
{ IVariable::DT_AUDIO_TRIGGER, "Audio Trigger", ePropertyAudioTrigger, 6 },
|
||||
|
||||
@@ -50,7 +50,7 @@ enum PropertyType
|
||||
ePropertyUser,
|
||||
ePropertySequenceId,
|
||||
ePropertyLightAnimation,
|
||||
ePropertyFlare,
|
||||
ePropertyDeprecated1, // formerly ePropertyFlare
|
||||
ePropertyParticleName,
|
||||
ePropertyGeomCache,
|
||||
ePropertyAudioTrigger,
|
||||
|
||||
@@ -13,6 +13,5 @@ set(FILES
|
||||
main.cpp
|
||||
Style/Editor.qss
|
||||
Style/resources.qrc
|
||||
Style/LensFlareEditor.qss
|
||||
EditorCryEdit.rc
|
||||
)
|
||||
|
||||
@@ -545,9 +545,6 @@ set(FILES
|
||||
Geometry/TriMesh.h
|
||||
AboutDialog.h
|
||||
AboutDialog.ui
|
||||
DatabaseFrameWnd.h
|
||||
DatabaseFrameWnd.ui
|
||||
DatabaseFrameWnd.qrc
|
||||
DocMultiArchive.h
|
||||
EditMode/DeepSelection.h
|
||||
FBXExporterDialog.h
|
||||
@@ -571,31 +568,6 @@ set(FILES
|
||||
WipFeaturesDlg.qrc
|
||||
LevelIndependentFileMan.cpp
|
||||
LevelIndependentFileMan.h
|
||||
LensFlareEditor/ILensFlareListener.h
|
||||
LensFlareEditor/LensFlareAtomicList.cpp
|
||||
LensFlareEditor/LensFlareAtomicList.h
|
||||
LensFlareEditor/LensFlareEditor.cpp
|
||||
LensFlareEditor/LensFlareEditor.h
|
||||
LensFlareEditor/LensFlareElement.cpp
|
||||
LensFlareEditor/LensFlareElement.h
|
||||
LensFlareEditor/LensFlareElementTree.cpp
|
||||
LensFlareEditor/LensFlareElementTree.h
|
||||
LensFlareEditor/LensFlareItem.cpp
|
||||
LensFlareEditor/LensFlareItem.h
|
||||
LensFlareEditor/LensFlareItemTree.cpp
|
||||
LensFlareEditor/LensFlareItemTree.h
|
||||
LensFlareEditor/LensFlareLibrary.cpp
|
||||
LensFlareEditor/LensFlareLibrary.h
|
||||
LensFlareEditor/LensFlareLightEntityTree.cpp
|
||||
LensFlareEditor/LensFlareLightEntityTree.h
|
||||
LensFlareEditor/LensFlareManager.cpp
|
||||
LensFlareEditor/LensFlareManager.h
|
||||
LensFlareEditor/LensFlareUndo.cpp
|
||||
LensFlareEditor/LensFlareUndo.h
|
||||
LensFlareEditor/LensFlareUtil.cpp
|
||||
LensFlareEditor/LensFlareUtil.h
|
||||
LensFlareEditor/LensFlareView.cpp
|
||||
LensFlareEditor/LensFlareView.h
|
||||
LogFileImpl.cpp
|
||||
LogFileImpl.h
|
||||
MatEditPreviewDlg.cpp
|
||||
@@ -706,7 +678,6 @@ set(FILES
|
||||
GraphicsSettingsDialog.cpp
|
||||
graphicssettingsdialog.ui
|
||||
AboutDialog.cpp
|
||||
DatabaseFrameWnd.cpp
|
||||
ErrorReportTableModel.h
|
||||
ErrorReportTableModel.cpp
|
||||
EditMode/DeepSelection.cpp
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include <AzToolsFramework/ToolsComponents/EditorEntityIconComponentBus.h>
|
||||
#include <AzToolsFramework/Undo/UndoCacheInterface.h>
|
||||
#include <LmbrCentral/Rendering/RenderNodeBus.h>
|
||||
#include <LmbrCentral/Rendering/MeshComponentBus.h>
|
||||
#include <LmbrCentral/Rendering/MaterialOwnerBus.h>
|
||||
|
||||
#include <IDisplayViewport.h>
|
||||
@@ -112,7 +111,6 @@ void CComponentEntityObject::AssignEntity(AZ::Entity* entity, bool destroyOld)
|
||||
{
|
||||
AZ::TransformNotificationBus::Handler::BusDisconnect();
|
||||
LmbrCentral::RenderBoundsNotificationBus::Handler::BusDisconnect();
|
||||
LmbrCentral::MeshComponentNotificationBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::ComponentEntityEditorRequestBus::Handler::BusDisconnect();
|
||||
AZ::EntityBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::ComponentEntityObjectRequestBus::Handler::BusDisconnect();
|
||||
@@ -158,7 +156,6 @@ void CComponentEntityObject::AssignEntity(AZ::Entity* entity, bool destroyOld)
|
||||
|
||||
AZ::TransformNotificationBus::Handler::BusConnect(m_entityId);
|
||||
LmbrCentral::RenderBoundsNotificationBus::Handler::BusConnect(m_entityId);
|
||||
LmbrCentral::MeshComponentNotificationBus::Handler::BusConnect(m_entityId);
|
||||
AzToolsFramework::ComponentEntityEditorRequestBus::Handler::BusConnect(m_entityId);
|
||||
AZ::EntityBus::Handler::BusConnect(m_entityId);
|
||||
AzToolsFramework::ComponentEntityObjectRequestBus::Handler::BusConnect(this);
|
||||
@@ -399,15 +396,6 @@ void CComponentEntityObject::OnParentChanged([[maybe_unused]] AZ::EntityId oldPa
|
||||
{
|
||||
}
|
||||
|
||||
void CComponentEntityObject::OnMeshCreated(const AZ::Data::Asset<AZ::Data::AssetData>& asset)
|
||||
{
|
||||
(void)asset;
|
||||
|
||||
// Need to recalculate bounds when the mesh changes.
|
||||
OnRenderBoundsReset();
|
||||
ValidateMeshStatObject();
|
||||
}
|
||||
|
||||
void CComponentEntityObject::OnRenderBoundsReset()
|
||||
{
|
||||
CEntityObject::InvalidateTM(0);
|
||||
@@ -950,9 +938,7 @@ void CComponentEntityObject::DrawDefault(DisplayContext& dc, const QColor& label
|
||||
|
||||
IStatObj* CComponentEntityObject::GetIStatObj()
|
||||
{
|
||||
IStatObj* statObj = nullptr;
|
||||
LmbrCentral::LegacyMeshComponentRequestBus::EventResult(statObj, m_entityId, &LmbrCentral::LegacyMeshComponentRequests::GetStatObj);
|
||||
return statObj;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CComponentEntityObject::IsIsolated() const
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <QtViewPane.h>
|
||||
|
||||
#include "../Editor/Objects/EntityObject.h"
|
||||
#include <LmbrCentral/Rendering/MeshComponentBus.h>
|
||||
#include <LmbrCentral/Rendering/RenderBoundsBus.h>
|
||||
#endif
|
||||
|
||||
@@ -43,7 +42,6 @@ class CComponentEntityObject
|
||||
, private AzToolsFramework::EditorEntityIconComponentNotificationBus::Handler
|
||||
, private AZ::TransformNotificationBus::Handler
|
||||
, private LmbrCentral::RenderBoundsNotificationBus::Handler
|
||||
, private LmbrCentral::MeshComponentNotificationBus::Handler
|
||||
, private AzToolsFramework::ComponentEntityEditorRequestBus::Handler
|
||||
, private AzToolsFramework::ComponentEntityObjectRequestBus::Handler
|
||||
, private AZ::EntityBus::Handler
|
||||
@@ -131,11 +129,6 @@ public:
|
||||
void OnParentChanged(AZ::EntityId oldParent, AZ::EntityId newParent) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! MeshComponentNotificationBus
|
||||
void OnMeshCreated(const AZ::Data::Asset<AZ::Data::AssetData>& asset) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! RenderBoundsNotificationBus
|
||||
void OnRenderBoundsReset() override;
|
||||
|
||||
@@ -13,9 +13,13 @@ if(NOT PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/Platform/${PAL_PLATFORM_NAME}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
|
||||
|
||||
# AssetBundlerBatch - CLI Application
|
||||
ly_add_target(
|
||||
NAME AssetBundler.Static STATIC
|
||||
NAME AssetBundlerBatch.Static STATIC
|
||||
NAMESPACE AZ
|
||||
AUTOMOC
|
||||
FILES_CMAKE
|
||||
assetbundlerbatch_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
@@ -23,6 +27,9 @@ ly_add_target(
|
||||
.
|
||||
BUILD_DEPENDENCIES
|
||||
PUBLIC
|
||||
3rdParty::Qt::Core
|
||||
3rdParty::Qt::Gui
|
||||
3rdParty::Qt::Widgets
|
||||
AZ::AzToolsFramework
|
||||
${additional_dependencies}
|
||||
)
|
||||
@@ -32,12 +39,41 @@ ly_add_target(
|
||||
NAMESPACE AZ
|
||||
FILES_CMAKE
|
||||
assetbundlerbatch_exe_files.cmake
|
||||
COMPILE_DEFINITIONS
|
||||
PRIVATE
|
||||
AB_BATCH_MODE
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
.
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AssetBundler.Static
|
||||
AZ::AssetBundlerBatch.Static
|
||||
)
|
||||
|
||||
# AssetBundler - Qt GUI Application
|
||||
ly_add_target(
|
||||
NAME AssetBundler ${PAL_TRAIT_BUILD_ASSETBUNDLER_APPLICATION_TYPE}
|
||||
NAMESPACE AZ
|
||||
AUTOMOC
|
||||
AUTOUIC
|
||||
AUTORCC
|
||||
FILES_CMAKE
|
||||
assetbundlergui_files.cmake
|
||||
assetbundler_exe_files.cmake
|
||||
Platform/${PAL_PLATFORM_NAME}/assetbundlergui_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PUBLIC
|
||||
Platform/${PAL_PLATFORM_NAME}
|
||||
PRIVATE
|
||||
.
|
||||
BUILD_DEPENDENCIES
|
||||
PUBLIC
|
||||
3rdParty::Qt::Core
|
||||
3rdParty::Qt::Gui
|
||||
3rdParty::Qt::Widgets
|
||||
AZ::AzToolsFramework
|
||||
AZ::AssetBundlerBatch.Static
|
||||
${additional_dependencies}
|
||||
)
|
||||
|
||||
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
@@ -53,7 +89,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzTest
|
||||
AZ::AssetBundler.Static
|
||||
AZ::AssetBundlerBatch.Static
|
||||
AZ::AzFrameworkTestShared
|
||||
)
|
||||
|
||||
|
||||
+2
-1
@@ -9,4 +9,5 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(DYAD_LIBS ${BASE_PATH}/lib/linux_$<IF:$<CONFIG:Debug>,debug,release>/libdyad.a)
|
||||
set (PAL_TRAIT_BUILD_ASSETBUNDLER_APPLICATION_TYPE APPLICATION)
|
||||
|
||||
+3
-1
@@ -9,4 +9,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(DYAD_LIBS ${BASE_PATH}/lib/x64_v140_$<IF:$<CONFIG:Debug>,Debug,Release>/libdyad.lib)
|
||||
set(FILES
|
||||
source/utils/GUIApplicationManager_Linux.cpp
|
||||
)
|
||||
+8
-4
@@ -10,8 +10,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#DatabaseFrameWnd QToolBar
|
||||
{
|
||||
border-bottom: 2px solid #111111;
|
||||
}
|
||||
#include <AzQtComponents/Components/WindowDecorationWrapper.h>
|
||||
|
||||
namespace Platform
|
||||
{
|
||||
AzQtComponents::WindowDecorationWrapper::Option GetWindowDecorationWrapperOption()
|
||||
{
|
||||
return AzQtComponents::WindowDecorationWrapper::OptionDisabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set (PAL_TRAIT_BUILD_ASSETBUNDLER_APPLICATION_TYPE APPLICATION)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user