promote som misc work
This commit is contained in:
parent
44bb2eae02
commit
f1477e03da
|
@ -1,8 +1,14 @@
|
|||
import Scripts.VSProp as VSProp
|
||||
import VSProp
|
||||
import os
|
||||
import sys
|
||||
|
||||
# ======================== const define
|
||||
# =========== check work dir ===========
|
||||
|
||||
if not os.path.isfile(os.path.join(os.getcwd(), 'README.md')):
|
||||
print('Error! Please run this script at the root of this repository.')
|
||||
sys.exit(1)
|
||||
|
||||
# =========== const define ===========
|
||||
|
||||
build_type_standalone = "standalone"
|
||||
build_type_plugin = "plugin"
|
||||
|
@ -68,7 +74,7 @@ valid_vt21_reverse_work_type = (
|
|||
'doyagu'
|
||||
)
|
||||
|
||||
# ======================== assist func
|
||||
# =========== assist func ===========
|
||||
def get_executable_virtools(vt_ver):
|
||||
if vt_ver == '21':
|
||||
return 'Dev.exe'
|
||||
|
@ -81,7 +87,7 @@ def get_executable_virtools(vt_ver):
|
|||
elif vt_ver == '50':
|
||||
return 'devr.exe'
|
||||
|
||||
# ======================== requirement get
|
||||
# =========== requirement get ===========
|
||||
|
||||
# get basic cfg, such as build type, and vt version
|
||||
while True:
|
||||
|
@ -147,8 +153,7 @@ else:
|
|||
else:
|
||||
break
|
||||
|
||||
# ======================== construct some path
|
||||
# .......todo
|
||||
# =========== construct some path ===========
|
||||
|
||||
# build sqlite related data
|
||||
sqlite_header_path = input_sqlite_header_path
|
||||
|
@ -226,7 +231,7 @@ else:
|
|||
virtools_lib_path = os.path.join(input_virtools_root_path, 'Sdk/Lib/Win32/Release')
|
||||
|
||||
|
||||
# ======================== create props
|
||||
# =========== create props ===========
|
||||
|
||||
props = VSProp.VSPropWriter()
|
||||
vcxproj = VSProp.VSVcxprojModifier('./SuperScriptMaterializer/SuperScriptMaterializer.vcxproj')
|
||||
|
@ -270,7 +275,7 @@ props.AddMacro('VIRTOOLS_MODULE_DEFINE', virtools_module_define)
|
|||
props.Write2File('./SuperScriptMaterializer/Virtools.props')
|
||||
vcxproj.Write2File()
|
||||
|
||||
# ======================== create vt21 props
|
||||
# =========== create vt21 props ===========
|
||||
|
||||
# if we are using virtools 2.1. and we use gamepiaynmo as our
|
||||
# reverse library. we need enable project GPVirtoolsStatic and
|
14
SuperScriptDecorator/.vscode/launch.json
vendored
Normal file
14
SuperScriptDecorator/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "SSDecorator",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "SuperScriptDecorator.py",
|
||||
"console": "integratedTerminal",
|
||||
"args": ["-d", "-i", "../example.txt", "-o", "decorate.db"],
|
||||
"justMyCode": false
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,8 +1,58 @@
|
|||
import locale
|
||||
import locale, sys, os, shlex
|
||||
|
||||
# encoding list
|
||||
# https://docs.python.org/3/library/codecs.html#standard-encodings
|
||||
database_encoding = locale.getpreferredencoding()
|
||||
export_db = "import.txt"
|
||||
decorated_db = "decorate.db"
|
||||
debug_mode = False
|
||||
class InputEntry(object):
|
||||
def __init__(self, data: tuple[str]):
|
||||
if len(data) != 4:
|
||||
raise Exception(f"Input syntax error. Require 4 items but got {len(data)}")
|
||||
self.m_Name: str = data[0]
|
||||
self.m_VtFile: str = data[1]
|
||||
self.m_ExportDb: str = data[2]
|
||||
self.m_EnvDb: str = data[3]
|
||||
|
||||
class CustomConfig(object):
|
||||
def __init__(self):
|
||||
# encoding list
|
||||
# https://docs.python.org/3/library/codecs.html#standard-encodings
|
||||
self.m_DatabaseEncoding: str = locale.getpreferredencoding()
|
||||
self.m_DebugMode = False
|
||||
|
||||
self.m_ImportTxt: str = None
|
||||
self.m_DecoratedDb: str = None
|
||||
|
||||
self.m_InputEntries: list[InputEntry] = []
|
||||
|
||||
def Regulate(self) -> bool:
|
||||
# check input and output
|
||||
if self.m_ImportTxt is None:
|
||||
print("No input. Decorator exit.")
|
||||
return False
|
||||
if not os.path.isfile(self.m_ImportTxt):
|
||||
print(f'No such input: "{self.m_ImportTxt}"')
|
||||
return False
|
||||
|
||||
if self.m_DecoratedDb is None:
|
||||
print("No output. Decorator exit.")
|
||||
return False
|
||||
if os.path.isdir(self.m_DecoratedDb):
|
||||
print("Output must be a file.")
|
||||
return False
|
||||
|
||||
# remove result database in debug mode
|
||||
if self.m_DebugMode and os.path.isfile(self.m_DecoratedDb):
|
||||
os.remove(self.m_DecoratedDb)
|
||||
|
||||
# process input file
|
||||
try:
|
||||
with open(self.m_ImportTxt, 'r', encoding='utf-8') as f:
|
||||
while True:
|
||||
ln = f.readline()
|
||||
if ln == '': break
|
||||
ln.strip()
|
||||
if ln == '': continue
|
||||
|
||||
self.m_InputEntries.append(InputEntry(shlex.split(ln)))
|
||||
except Exception as ex:
|
||||
print("Errro when processing input file.")
|
||||
print(ex)
|
||||
|
||||
return True
|
||||
|
|
|
@ -1,29 +1,51 @@
|
|||
import sys
|
||||
|
||||
value_All = 0
|
||||
value_Now = 0
|
||||
progressbar_span = 2
|
||||
progressbar_count = int(100/progressbar_span)
|
||||
class Prograssbar(object):
|
||||
def __init__(self, filecount: int):
|
||||
if (filecount < 0): raise Exception("Progressbar can not hold minus length!")
|
||||
|
||||
def initProgressbar(all):
|
||||
global value_Now, value_All
|
||||
value_All = all
|
||||
value_Now = 0
|
||||
self.__FileCount: int = filecount
|
||||
self.__FileNow: int = 0
|
||||
self.__ContentCount: int = 0
|
||||
self.__ContentNow: int = 0
|
||||
|
||||
sys.stdout.write('[{}] 0%'.format(progressbar_count * '='))
|
||||
sys.stdout.flush()
|
||||
self.__PbarFullChar: int = 50
|
||||
self.__PercentPerFile: float = 1 / self.__FileCount
|
||||
self.__CurFileName: str = None
|
||||
|
||||
def stepProgressbar():
|
||||
global value_Now, value_All
|
||||
value_Now += 1
|
||||
if (value_Now > value_All):
|
||||
value_Now = value_All
|
||||
self.__Render()
|
||||
|
||||
percentage = int(value_Now / value_All * 100)
|
||||
percentage_bar = int(value_Now / value_All * progressbar_count)
|
||||
sys.stdout.write('\r[{}{}] {}%'.format(percentage_bar * '#',(progressbar_count - percentage_bar) * '=', percentage))
|
||||
sys.stdout.flush()
|
||||
def StepFile(self, newfile: str, content_len: int):
|
||||
if self.__CurFileName is not None:
|
||||
# not first call, INC FileNow
|
||||
# if first call, do not INC it
|
||||
self.__FileNow += 1
|
||||
# apply others
|
||||
self.__CurFileName = newfile
|
||||
self.__ContentNow = 0
|
||||
self.__ContentCount = content_len
|
||||
|
||||
def finProgressbar():
|
||||
sys.stdout.write('\r[{}] 100%\n'.format(progressbar_count * '#'))
|
||||
sys.stdout.flush()
|
||||
self.__Render()
|
||||
|
||||
def StepContent(self):
|
||||
self.__ContentNow += 1
|
||||
|
||||
self.__Render()
|
||||
|
||||
def Finish(self):
|
||||
sys.stdout.write('\n')
|
||||
sys.stdout.flush()
|
||||
|
||||
def __Render(self):
|
||||
percentage_content: float = 0 if self.__ContentCount == 0 else (self.__ContentNow / self.__ContentCount)
|
||||
percentage_full: float = (percentage_content + self.__FileNow) * self.__PercentPerFile
|
||||
|
||||
percentage_bar = int(percentage_full * self.__PbarFullChar)
|
||||
|
||||
sys.stdout.write('\r[{}{}] {:.2f}% - {}'.format(
|
||||
percentage_bar * '#',
|
||||
(self.__PbarFullChar - percentage_bar) * '=',
|
||||
percentage_full * 100,
|
||||
self.__CurFileName
|
||||
))
|
||||
sys.stdout.flush()
|
||||
|
|
|
@ -1,53 +1,51 @@
|
|||
import CustomConfig
|
||||
import DecoratorCore
|
||||
import os
|
||||
import sys
|
||||
import getopt
|
||||
import logging
|
||||
import CustomConfig, DecoratorCore, Progressbar
|
||||
import os, sys, getopt, logging, time
|
||||
|
||||
# print banner
|
||||
print('Super Script Decorator')
|
||||
print('Homepage: https://github.com/yyc12345/SuperScriptMaterializer')
|
||||
print('Report bug: https://github.com/yyc12345/SuperScriptMaterializer/issues')
|
||||
print('')
|
||||
|
||||
# try get args
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "hi:o:e:c:fd")
|
||||
except getopt.GetoptError:
|
||||
print('Wrong arguments!')
|
||||
print('python SuperScriptViewer.py -i <import.txt> -o <decorated.db> -c <codec_name> -d')
|
||||
sys.exit(1)
|
||||
|
||||
# analyze args
|
||||
cfg: CustomConfig.CustomConfig = CustomConfig.CustomConfig()
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print('python SuperScriptViewer.py -i <import.txt> -o <decorated.db> -c <codec_name> -d')
|
||||
sys.exit(0)
|
||||
elif opt == '-i':
|
||||
CustomConfig.export_db = arg
|
||||
cfg.m_ImportTxt = arg
|
||||
elif opt == '-o':
|
||||
CustomConfig.decorated_db = arg
|
||||
cfg.m_DecoratedDb = arg
|
||||
elif opt == '-c':
|
||||
CustomConfig.database_encoding = arg
|
||||
cfg.m_DatabaseEncoding = arg
|
||||
elif opt == '-d':
|
||||
CustomConfig.debug_mode = True
|
||||
cfg.m_DebugMode = True
|
||||
|
||||
print('Super Script Decorator')
|
||||
print('Homepage: https://github.com/yyc12345/SuperScriptMaterializer')
|
||||
print('Report bug: https://github.com/yyc12345/SuperScriptMaterializer/issues')
|
||||
print('')
|
||||
|
||||
# process input and output
|
||||
if not os.path.isfile(CustomConfig.export_db):
|
||||
print('No import.txt. Fail to generate. Exit app.')
|
||||
# regulate data
|
||||
if not cfg.Regulate():
|
||||
# failed. exit program
|
||||
sys.exit(1)
|
||||
|
||||
# real db generator func
|
||||
def dc_wrapper():
|
||||
pass
|
||||
|
||||
# generate db
|
||||
if CustomConfig.debug_mode:
|
||||
DecoratorCore.run()
|
||||
# if in debug mode, run directly
|
||||
# otherwise, run with a try wrapper.
|
||||
if cfg.m_DebugMode:
|
||||
DecoratorCore.run(cfg)
|
||||
else:
|
||||
try:
|
||||
DecoratorCore.run()
|
||||
except Exception, ex:
|
||||
DecoratorCore.run(cfg)
|
||||
except Exception as ex:
|
||||
print("!!! An error occurs. Please report follwoing error output and reproduce file to developer. !!!")
|
||||
logging.exception(ex)
|
||||
sys.exit(1)
|
||||
|
||||
print('Decorated database generating done.')
|
||||
|
||||
print('Decorated database generation done.')
|
||||
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>6d751bf5-87d6-4123-94b3-34721938cf04</ProjectGuid>
|
||||
<ProjectHome>.</ProjectHome>
|
||||
<StartupFile>SuperScriptDecorator.py</StartupFile>
|
||||
<SearchPath>
|
||||
</SearchPath>
|
||||
<WorkingDirectory>.</WorkingDirectory>
|
||||
<OutputPath>.</OutputPath>
|
||||
<Name>SuperScriptDecorator</Name>
|
||||
<RootNamespace>SuperScriptDecorator</RootNamespace>
|
||||
<LaunchProvider>Standard Python launcher</LaunchProvider>
|
||||
<CommandLineArguments>-f -d</CommandLineArguments>
|
||||
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CustomConfig.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DecoratorConstValue.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DecoratorCore.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Progressbar.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SuperScriptDecorator.py" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||
<!-- Uncomment the CoreCompile target to enable the Build command in
|
||||
Visual Studio and specify your pre- and post-build commands in
|
||||
the BeforeBuild and AfterBuild targets below. -->
|
||||
<!--<Target Name="CoreCompile" />-->
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
</Project>
|
|
@ -3,40 +3,22 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29418.71
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "SuperScriptDecorator", "SuperScriptDecorator\SuperScriptDecorator.pyproj", "{6D751BF5-87D6-4123-94B3-34721938CF04}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SuperScriptMaterializer", "SuperScriptMaterializer\SuperScriptMaterializer.vcxproj", "{4D941003-020F-47FD-9FA2-FFC989E306B8}"
|
||||
EndProject
|
||||
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "SuperScriptViewer", "SuperScriptViewer\SuperScriptViewer.pyproj", "{0E4B5021-27EA-4F79-B87D-E123AFB3D788}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GPVirtoolsStatic", "GPVirtoolsStatic\GPVirtoolsStatic.vcxproj", "{38703AB6-BC5D-4062-BC5B-1BF195333B16}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6D751BF5-87D6-4123-94B3-34721938CF04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6D751BF5-87D6-4123-94B3-34721938CF04}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{6D751BF5-87D6-4123-94B3-34721938CF04}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6D751BF5-87D6-4123-94B3-34721938CF04}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|x86.Build.0 = Debug|Win32
|
||||
{4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x86.ActiveCfg = Release|Win32
|
||||
{4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x86.Build.0 = Release|Win32
|
||||
{0E4B5021-27EA-4F79-B87D-E123AFB3D788}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0E4B5021-27EA-4F79-B87D-E123AFB3D788}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{0E4B5021-27EA-4F79-B87D-E123AFB3D788}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0E4B5021-27EA-4F79-B87D-E123AFB3D788}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{38703AB6-BC5D-4062-BC5B-1BF195333B16}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{38703AB6-BC5D-4062-BC5B-1BF195333B16}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{38703AB6-BC5D-4062-BC5B-1BF195333B16}.Debug|x86.Build.0 = Debug|Win32
|
||||
{38703AB6-BC5D-4062-BC5B-1BF195333B16}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{38703AB6-BC5D-4062-BC5B-1BF195333B16}.Release|x86.ActiveCfg = Release|Win32
|
||||
{38703AB6-BC5D-4062-BC5B-1BF195333B16}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>0e4b5021-27ea-4f79-b87d-e123afb3d788</ProjectGuid>
|
||||
<ProjectHome>.</ProjectHome>
|
||||
<StartupFile>SuperScriptViewer.py</StartupFile>
|
||||
<SearchPath>
|
||||
</SearchPath>
|
||||
<WorkingDirectory>.</WorkingDirectory>
|
||||
<OutputPath>.</OutputPath>
|
||||
<Name>SuperScriptViewer</Name>
|
||||
<RootNamespace>SuperScriptViewer</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CustomConfig.py" />
|
||||
<Compile Include="ServerCore.py" />
|
||||
<Compile Include="ServerStruct.py" />
|
||||
<Compile Include="SuperScriptViewer.py" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||
<!-- Uncomment the CoreCompile target to enable the Build command in
|
||||
Visual Studio and specify your pre- and post-build commands in
|
||||
the BeforeBuild and AfterBuild targets below. -->
|
||||
<!--<Target Name="CoreCompile" />-->
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
</Project>
|
2
example.txt
Normal file
2
example.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
Ballance/vt2obj "example.nmo" "export.db" "env.db"
|
||||
"Ballance/vt2obj mirror" Gameplay.nmo export.db env.db
|
Loading…
Reference in New Issue
Block a user