Skip to content

Commit

Permalink
增加:UnLuaSettings作为插件设置类
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyanghuang-tencent committed Nov 29, 2021
1 parent fdae2b4 commit a6a23a8
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 1 deletion.
43 changes: 42 additions & 1 deletion Plugins/UnLua/Source/UnLua/Private/UnLuaModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and limitations under the License.

#include "ISettingsModule.h"
#include "ISettingsSection.h"
#include "Modules/ModuleManager.h"
#include "LuaContext.h"
#include "UnLuaSettings.h"

#define LOCTEXT_NAMESPACE "FUnLuaModule"

Expand All @@ -22,13 +25,51 @@ class FUnLuaModule : public IModuleInterface
public:
virtual void StartupModule() override
{
FLuaContext::Create();
#if WITH_EDITOR
FCoreDelegates::OnFEngineLoopInitComplete.AddLambda([this] { RegisterSettings(); });
#endif
FLuaContext::Create();
GLuaCxt->RegisterDelegates();
}

virtual void ShutdownModule() override
{
#if WITH_EDITOR
UnregisterSettings();
#endif
}

private:
#if WITH_EDITOR
void RegisterSettings() const
{
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
if (SettingsModule)
{
const TSharedPtr<ISettingsSection> Section = SettingsModule->RegisterSettings("Project", "Plugins", "UnLua",
LOCTEXT("UnLuaSettingsName", "UnLua"),
LOCTEXT("UnLuaSettingsDescription", "Configure settings of UnLua."),
GetMutableDefault<UUnLuaSettings>());
Section->OnModified().BindRaw(this, &FUnLuaModule::OnSettingsModified);
}
}

void UnregisterSettings() const
{
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
if (SettingsModule)
SettingsModule->UnregisterSettings("Project", "Plugins", "UnLua");
}

bool OnSettingsModified() const
{
const UUnLuaSettings& Settings = *GetDefault<UUnLuaSettings>();

// TODO:

return true;
}
#endif
};

#undef LOCTEXT_NAMESPACE
Expand Down
15 changes: 15 additions & 0 deletions Plugins/UnLua/Source/UnLua/Private/UnLuaSettings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Tencent is pleased to support the open source community by making UnLua available.
//
// Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and limitations under the License.

#include "UnLuaSettings.h"
32 changes: 32 additions & 0 deletions Plugins/UnLua/Source/UnLua/Private/UnLuaSettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Tencent is pleased to support the open source community by making UnLua available.
//
// Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License. You may obtain a copy of the License at
//
// http://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and limitations under the License.

#pragma once

#include "CoreMinimal.h"
#include "UnLuaSettings.generated.h"


UCLASS(config=UnLua, defaultconfig, meta=(DisplayName="UnLua"))
class UNLUA_API UUnLuaSettings : public UObject
{
GENERATED_BODY()

public:
UPROPERTY(config, EditAnywhere, Category = "Setting", meta = (DisplayName = "Generate IntelliSense Files", defaultValue = false))
bool bGenerateIntelliSense;

UPROPERTY(config, EditAnywhere, Category = "Setting", meta = (DisplayName = "Enable Hot Reload", defaultValue = false))
bool bEnableHotReload;
};
1 change: 1 addition & 0 deletions TPSProject.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=collectgarbage/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=LOCTEXT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Quat/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tickable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tostring/@EntryIndexedValue">True</s:Boolean>
Expand Down

0 comments on commit a6a23a8

Please sign in to comment.