mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-27 09:36:15 +00:00
Merged develop
This commit is contained in:
commit
ea08136fdc
8 changed files with 1040 additions and 139 deletions
|
@ -234,10 +234,6 @@ CDriverGL::CDriverGL()
|
|||
_CursorScale = 1.f;
|
||||
_MouseCaptured = false;
|
||||
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
_BorderlessFullscreen = false;
|
||||
#endif
|
||||
|
||||
_NeedToRestaureGammaRamp = false;
|
||||
|
||||
_win = EmptyWindow;
|
||||
|
|
|
@ -996,12 +996,6 @@ private:
|
|||
EWindowStyle getWindowStyle() const;
|
||||
bool setWindowStyle(EWindowStyle windowStyle);
|
||||
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
static BOOL CALLBACK monitorEnumProcFullscreen(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData);
|
||||
bool _BorderlessFullscreen;
|
||||
#endif
|
||||
std::string _CurrentDisplayDevice;
|
||||
|
||||
// Methods to manage screen resolutions
|
||||
bool restoreScreenMode();
|
||||
bool saveScreenMode();
|
||||
|
|
|
@ -1271,86 +1271,10 @@ static sint modeInfoToFrequency(XF86VidModeModeInfo *info)
|
|||
|
||||
// ***************************************************************************
|
||||
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
|
||||
struct CMonitorEnumParams
|
||||
{
|
||||
public:
|
||||
CDriverGL *Driver;
|
||||
const char *DeviceName;
|
||||
bool Success;
|
||||
};
|
||||
|
||||
BOOL CALLBACK CDriverGL::monitorEnumProcFullscreen(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData)
|
||||
{
|
||||
CMonitorEnumParams *p = reinterpret_cast<CMonitorEnumParams *>(dwData);
|
||||
|
||||
MONITORINFOEXA monitorInfo;
|
||||
memset(&monitorInfo, 0, sizeof(monitorInfo));
|
||||
monitorInfo.cbSize = sizeof(monitorInfo);
|
||||
GetMonitorInfoA(hMonitor, &monitorInfo);
|
||||
nldebug("3D: Monitor: '%s'", monitorInfo.szDevice);
|
||||
|
||||
size_t devLen = strlen(monitorInfo.szDevice);
|
||||
size_t targetLen = strlen(p->DeviceName);
|
||||
|
||||
nlassert(devLen < 32);
|
||||
size_t minLen = min(devLen, targetLen);
|
||||
if (!memcmp(monitorInfo.szDevice, p->DeviceName, minLen))
|
||||
{
|
||||
if (devLen == targetLen
|
||||
|| (devLen < targetLen && (p->DeviceName[minLen] == '\\'))
|
||||
|| (devLen > targetLen && (monitorInfo.szDevice[minLen] == '\\')))
|
||||
{
|
||||
nldebug("3D: Remapping '%s' to '%s'", p->DeviceName, monitorInfo.szDevice);
|
||||
nldebug("3D: Found requested monitor at %i, %i", monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top);
|
||||
p->Driver->_CurrentMode.Windowed = false;
|
||||
p->Driver->setWindowStyle(CDriverGL::EWSWindowed);
|
||||
p->Driver->setWindowSize(monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top);
|
||||
LONG dwStyle = GetWindowLong(p->Driver->_win, GWL_STYLE);
|
||||
SetWindowLong(p->Driver->_win, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPos(p->Driver->_win, NULL,
|
||||
monitorInfo.rcMonitor.left,
|
||||
monitorInfo.rcMonitor.top,
|
||||
monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left,
|
||||
monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top,
|
||||
SWP_FRAMECHANGED);
|
||||
p->Driver->_WindowX = monitorInfo.rcMonitor.left;
|
||||
p->Driver->_WindowY = monitorInfo.rcMonitor.top;
|
||||
p->Driver->_CurrentDisplayDevice = std::string(p->DeviceName);
|
||||
p->Driver->_BorderlessFullscreen = true;
|
||||
p->Driver->_CurrentMode.Windowed = false;
|
||||
p->Success = true;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
p->Success = false;
|
||||
return TRUE; // continue
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
bool CDriverGL::setScreenMode(const GfxMode &mode)
|
||||
{
|
||||
H_AUTO_OGL(CDriverGL_setScreenMode)
|
||||
|
||||
nldebug("3D: setScreenMode");
|
||||
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
if (_BorderlessFullscreen)
|
||||
{
|
||||
_BorderlessFullscreen = false;
|
||||
LONG dwStyle = GetWindowLong(_win, GWL_STYLE);
|
||||
dwStyle |= WS_OVERLAPPEDWINDOW;
|
||||
if (!_Resizable) dwStyle ^= WS_MAXIMIZEBOX|WS_THICKFRAME;
|
||||
SetWindowLong(_win, GWL_STYLE, dwStyle);
|
||||
SetWindowPos(_win, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
||||
_CurrentMode.Windowed = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mode.Windowed)
|
||||
{
|
||||
// if fullscreen, switch back to desktop screen mode
|
||||
|
@ -1360,17 +1284,13 @@ bool CDriverGL::setScreenMode(const GfxMode &mode)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (_CurrentDisplayDevice != mode.DisplayDevice)
|
||||
restoreScreenMode();
|
||||
|
||||
// save previous screen mode only if switching from windowed to fullscreen
|
||||
if (_CurrentMode.Windowed)
|
||||
saveScreenMode();
|
||||
|
||||
// if switching exactly to the same screen mode, doesn't change it
|
||||
GfxMode previousMode;
|
||||
if (_CurrentDisplayDevice == mode.DisplayDevice
|
||||
&& getCurrentScreenMode(previousMode)
|
||||
if (getCurrentScreenMode(previousMode)
|
||||
&& mode.Width == previousMode.Width
|
||||
&& mode.Height == previousMode.Height
|
||||
&& mode.Depth == previousMode.Depth
|
||||
|
@ -1379,9 +1299,7 @@ bool CDriverGL::setScreenMode(const GfxMode &mode)
|
|||
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
|
||||
const char *deviceName = mode.DisplayDevice.c_str();
|
||||
|
||||
DEVMODEA devMode;
|
||||
DEVMODE devMode;
|
||||
memset(&devMode, 0, sizeof(DEVMODE));
|
||||
devMode.dmSize = sizeof(DEVMODE);
|
||||
devMode.dmDriverExtra = 0;
|
||||
|
@ -1389,42 +1307,22 @@ bool CDriverGL::setScreenMode(const GfxMode &mode)
|
|||
devMode.dmPelsWidth = mode.Width;
|
||||
devMode.dmPelsHeight = mode.Height;
|
||||
|
||||
if (mode.Depth > 0)
|
||||
if(mode.Depth > 0)
|
||||
{
|
||||
devMode.dmBitsPerPel = mode.Depth;
|
||||
devMode.dmFields |= DM_BITSPERPEL;
|
||||
}
|
||||
|
||||
if (mode.Frequency > 0)
|
||||
if(mode.Frequency > 0)
|
||||
{
|
||||
devMode.dmDisplayFrequency = mode.Frequency;
|
||||
devMode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||
}
|
||||
|
||||
if (deviceName[0])
|
||||
if (ChangeDisplaySettings(&devMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
// First attempt exclusive fullscreen
|
||||
nldebug("3D: ChangeDisplaySettingsEx");
|
||||
LONG resex;
|
||||
if ((resex = ChangeDisplaySettingsExA(deviceName, &devMode, NULL, CDS_FULLSCREEN, NULL)) != DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
nlwarning("3D: Fullscreen mode switch failed (%i)", (sint)resex);
|
||||
// Workaround, resize to monitor and make borderless
|
||||
CMonitorEnumParams p;
|
||||
p.DeviceName = deviceName;
|
||||
p.Driver = this;
|
||||
EnumDisplayMonitors(NULL, NULL, monitorEnumProcFullscreen, (LPARAM)&p);
|
||||
return p.Success;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nldebug("3D: ChangeDisplaySettings");
|
||||
if (ChangeDisplaySettingsA(&devMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
nlwarning("3D: Fullscreen mode switch failed");
|
||||
return false;
|
||||
}
|
||||
nlwarning("3D: Fullscreen mode switch failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
#elif defined(NL_OS_MAC)
|
||||
|
@ -1830,11 +1728,7 @@ bool CDriverGL::setWindowStyle(EWindowStyle windowStyle)
|
|||
dwNewStyle |= WS_VISIBLE;
|
||||
|
||||
if (dwStyle != dwNewStyle)
|
||||
{
|
||||
SetWindowLong(_win, GWL_STYLE, dwNewStyle);
|
||||
if (windowStyle == EWSWindowed)
|
||||
SetWindowPos(_win, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
||||
}
|
||||
|
||||
// if (windowStyle == EWSMaximized && isVisible && !isMaximized)
|
||||
// ShowWindow(_hWnd, SW_SHOWMAXIMIZED);
|
||||
|
@ -1962,24 +1856,19 @@ bool CDriverGL::setMode(const GfxMode& mode)
|
|||
&& ScreenToClient(_win, &cursorPos);
|
||||
sint curX = (sint)cursorPos.x * (sint)mode.Width;
|
||||
sint curY = (sint)cursorPos.y * (sint)mode.Height;
|
||||
if (_BorderlessFullscreen)
|
||||
ReleaseCapture();
|
||||
#endif
|
||||
|
||||
if (!setScreenMode(mode))
|
||||
return false;
|
||||
|
||||
if (!_BorderlessFullscreen)
|
||||
{
|
||||
// when changing window style, it's possible system change window size too
|
||||
setWindowStyle(mode.Windowed ? EWSWindowed : EWSFullscreen);
|
||||
// when changing window style, it's possible system change window size too
|
||||
setWindowStyle(mode.Windowed ? EWSWindowed : EWSFullscreen);
|
||||
|
||||
if (!mode.Windowed)
|
||||
_CurrentMode.Depth = mode.Depth;
|
||||
if (!mode.Windowed)
|
||||
_CurrentMode.Depth = mode.Depth;
|
||||
|
||||
setWindowSize(mode.Width, mode.Height);
|
||||
setWindowPos(_WindowX, _WindowY);
|
||||
}
|
||||
setWindowSize(mode.Width, mode.Height);
|
||||
setWindowPos(_WindowX, _WindowY);
|
||||
|
||||
switch (_CurrentMode.Depth)
|
||||
{
|
||||
|
@ -1996,8 +1885,6 @@ bool CDriverGL::setMode(const GfxMode& mode)
|
|||
cursorPos.y = curY / (sint)mode.Height;
|
||||
ClientToScreen(_win, &cursorPos);
|
||||
SetCursorPos(cursorPos.x, cursorPos.y);
|
||||
if (_BorderlessFullscreen)
|
||||
SetCapture(_win);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
378
code/nel/tools/3d/plugin_max/scripts/nel_assets_ps_batched.ms
Normal file
378
code/nel/tools/3d/plugin_max/scripts/nel_assets_ps_batched.ms
Normal file
|
@ -0,0 +1,378 @@
|
|||
|
||||
NEL3D_APPDATA_INTERFACE_FILE = 1423062700
|
||||
|
||||
-- Allocate 20 Me for the script
|
||||
heapSize += 15000000
|
||||
|
||||
nlErrorFilename = "W:/database/conversion.log"
|
||||
nlErrorStream = openFile nlErrorFilename mode:"w"
|
||||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Log a message
|
||||
fn nllog message =
|
||||
(
|
||||
if nlErrorStream != undefined then
|
||||
(
|
||||
format "%\n" message to:nlErrorStream
|
||||
flush nlErrorStream
|
||||
)
|
||||
|
||||
-- To the console
|
||||
print message
|
||||
)
|
||||
|
||||
include "nel_utility.ms"
|
||||
|
||||
fn findFile dir fileName =
|
||||
(
|
||||
if (doesFileExist (dir + "\\" + fileName)) then
|
||||
(
|
||||
return (dir + "\\" + fileName)
|
||||
)
|
||||
|
||||
dirArr = GetDirectories (dir + "\\*")
|
||||
|
||||
for d in dirArr do
|
||||
(
|
||||
local fileFound = findFile d fileName
|
||||
if (fileFound != "") then
|
||||
return fileFound
|
||||
)
|
||||
|
||||
return ""
|
||||
)
|
||||
|
||||
fn getFixedPath ps =
|
||||
(
|
||||
if not (doesFileExist ps) then
|
||||
(
|
||||
local fileName = filenameFromPath ps
|
||||
local fileFound = findFile "W:\\database\\sfx" fileName
|
||||
if (fileFound != "") then
|
||||
return fileFound
|
||||
else
|
||||
return fileName
|
||||
)
|
||||
else
|
||||
(
|
||||
return ps
|
||||
)
|
||||
)
|
||||
|
||||
fn renameParticleSystem ps =
|
||||
(
|
||||
local newFileName = getFixedPath ps.ps_file_name
|
||||
if (newFileName != ps.ps_file_name) then
|
||||
(
|
||||
ps.ps_file_name = newFileName
|
||||
return 1
|
||||
)
|
||||
else
|
||||
(
|
||||
return 0
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
rollout assets_ps_rollout "Properties"
|
||||
(
|
||||
fn do_it =
|
||||
(
|
||||
local result = 0
|
||||
|
||||
for m in getClassInstances nel_ps do
|
||||
(
|
||||
if (renameParticleSystem m) == 1 then
|
||||
result = 1
|
||||
)
|
||||
|
||||
max select none
|
||||
|
||||
actionMan.executeAction 0 "40021" -- Selection: Select All
|
||||
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
|
||||
actionMan.executeAction 0 "40807" -- Views: Activate All Maps
|
||||
actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps
|
||||
actionMan.executeAction 0 "40043" -- Selection: Select None
|
||||
|
||||
max views redraw
|
||||
|
||||
return result
|
||||
)
|
||||
|
||||
-- This script is a base script to include to add multiple functionality to your script
|
||||
|
||||
-- To use this script
|
||||
-- Include it in your script into the rollout at the beginning.
|
||||
-- Implement a do_it function to do the job in your rollout.
|
||||
-- The function should retun -1 if an arror occured, else the count of modification done
|
||||
-- It the function returns <1, the project will not be overwritten
|
||||
|
||||
Group "Running properties"
|
||||
(
|
||||
RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left
|
||||
|
||||
Label DirectoryLabel "Source directory" align:#left
|
||||
EditText Directory "" width:500 align:#left enabled:false
|
||||
Button BrowseDirectory "Browse..." align:#left enabled:false
|
||||
|
||||
CheckBox Recurse "Look in subfolders" checked:true enabled:false
|
||||
CheckBox Test "Test only, do not save" checked:false enabled:false
|
||||
CheckBox BackupFiles "Backup files" checked:false enabled:false
|
||||
CheckBox StopOnError "Stop on error" checked:false enabled:false
|
||||
CheckBox UseTag "Use tag" checked:false enabled:false
|
||||
|
||||
Label ProgressText width:500 align:#left
|
||||
ProgressBar Progress width:500 align:#left
|
||||
|
||||
Button GoButton "Go" width:500 align:#left
|
||||
)
|
||||
|
||||
local countModifications
|
||||
local countErrors
|
||||
local fileModified
|
||||
local fileParsed
|
||||
|
||||
fn UpdateData =
|
||||
(
|
||||
if SourceFiles.state == 2 then
|
||||
isSourceDir = true
|
||||
else
|
||||
isSourceDir = false
|
||||
if Test.checked == true then
|
||||
isTest = true
|
||||
else
|
||||
isTest = false
|
||||
|
||||
Directory.enabled = isSourceDir
|
||||
BrowseDirectory.enabled = isSourceDir
|
||||
Recurse.enabled = isSourceDir
|
||||
Test.enabled = isSourceDir
|
||||
BackupFiles.enabled = isSourceDir and (isTest == false)
|
||||
StopOnError.enabled = isSourceDir
|
||||
UseTag.enabled = isSourceDir
|
||||
)
|
||||
|
||||
on SourceFiles changed state do
|
||||
(
|
||||
UpdateData ()
|
||||
)
|
||||
|
||||
on Test changed state do
|
||||
(
|
||||
UpdateData ()
|
||||
)
|
||||
|
||||
fn call_do_it =
|
||||
(
|
||||
local result
|
||||
|
||||
-- One more project
|
||||
fileParsed = fileParsed + 1
|
||||
|
||||
-- Call it
|
||||
result = do_it ()
|
||||
|
||||
-- Error ?
|
||||
if result < 0 then
|
||||
countErrors = countErrors + 1
|
||||
else
|
||||
countModifications = countModifications + result
|
||||
|
||||
-- Return result
|
||||
return result
|
||||
)
|
||||
|
||||
fn BackupFile file =
|
||||
(
|
||||
local i
|
||||
local newFilename
|
||||
|
||||
i = 0
|
||||
while true do
|
||||
(
|
||||
-- New file name
|
||||
newFilename = file + ".backup_" + (i as string)
|
||||
|
||||
-- File exist ?
|
||||
if (fileExist newFilename) == false then
|
||||
(
|
||||
if (copyFile file newFilename) == false then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
)
|
||||
i = i + 1
|
||||
)
|
||||
)
|
||||
|
||||
fn RecurseFolder currentDirectory =
|
||||
(
|
||||
resetMAXFile #noprompt
|
||||
|
||||
local result
|
||||
local file
|
||||
local files
|
||||
local origAnimStart
|
||||
local origAnimEnd
|
||||
local origFrameRate
|
||||
|
||||
-- Parse files
|
||||
files = getFiles (currentDirectory+"/*.max")
|
||||
|
||||
-- For each files
|
||||
for i = 1 to files.count do
|
||||
(
|
||||
-- File name
|
||||
file = files[i]
|
||||
|
||||
-- Progress bar
|
||||
ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\""
|
||||
Progress.value = i*100/files.count
|
||||
|
||||
if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then
|
||||
(
|
||||
resetMAXFile #noprompt
|
||||
|
||||
nllog("CONVERT " + file)
|
||||
|
||||
-- Open the max project
|
||||
if loadMaxFile file quiet:true == true then
|
||||
(
|
||||
objXRefMgr.UpdateAllRecords()
|
||||
|
||||
result = call_do_it ()
|
||||
|
||||
-- Error ?
|
||||
if result < 0 then
|
||||
(
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Error in file " + file)
|
||||
)
|
||||
else
|
||||
(
|
||||
-- Save the max project ?
|
||||
if (Test.checked == false) and (result != 0) then
|
||||
(
|
||||
-- Backup the max project ?
|
||||
local ok
|
||||
ok = true
|
||||
if BackupFiles.checked == true then
|
||||
(
|
||||
-- Backup the file
|
||||
if (BackupFile file) == false then
|
||||
(
|
||||
-- Don't save the file because backup has failed
|
||||
ok = false
|
||||
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Can't backup file " + file)
|
||||
|
||||
-- One more error
|
||||
countErrors = countErrors + 1
|
||||
)
|
||||
)
|
||||
|
||||
-- Save the max project ?
|
||||
if ok == true then
|
||||
(
|
||||
if (saveMaxFile file) == true then
|
||||
(
|
||||
fileModified = fileModified + 1
|
||||
)
|
||||
else
|
||||
(
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Can't write file " + file)
|
||||
|
||||
-- One more error
|
||||
countErrors = countErrors + 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
else
|
||||
(
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Can't load file " + file)
|
||||
|
||||
-- One more error
|
||||
countErrors = countErrors + 1
|
||||
)
|
||||
)
|
||||
else
|
||||
(
|
||||
nllog("SKIP " + file + " by tag")
|
||||
)
|
||||
)
|
||||
|
||||
-- Parse sub directory ?
|
||||
if (Recurse.checked == true) then
|
||||
(
|
||||
local directories
|
||||
|
||||
-- Get the directories
|
||||
directories = getDirectories (currentDirectory+"/*")
|
||||
|
||||
-- For each directories
|
||||
for dir in directories do
|
||||
(
|
||||
RecurseFolder dir
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
on BrowseDirectory pressed do
|
||||
(
|
||||
local dir
|
||||
try
|
||||
(
|
||||
dir = getSavePath () -- caption:"Select the projects directory"
|
||||
if dir != undefined then
|
||||
Directory.text = dir
|
||||
)
|
||||
catch
|
||||
(
|
||||
)
|
||||
)
|
||||
|
||||
on GoButton pressed do
|
||||
(
|
||||
-- Reset count
|
||||
countModifications = 0
|
||||
countErrors = 0
|
||||
fileModified = 0
|
||||
fileParsed = 0
|
||||
|
||||
-- Get files in the shape_source_directory
|
||||
if SourceFiles.state == 2 then
|
||||
(
|
||||
-- Should warning user ?
|
||||
if (SourceFiles.state == 2) and (Test.checked == false) then
|
||||
(
|
||||
-- Warning !
|
||||
if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then
|
||||
RecurseFolder (adjustPathStringForScript Directory.text)
|
||||
)
|
||||
else
|
||||
(
|
||||
RecurseFolder (adjustPathStringForScript Directory.text)
|
||||
)
|
||||
)
|
||||
else
|
||||
(
|
||||
-- Just compute the current project
|
||||
call_do_it ()
|
||||
)
|
||||
|
||||
-- Show errors
|
||||
ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)."
|
||||
Progress.value = 100
|
||||
)
|
||||
)
|
||||
|
||||
assets_ps_floater = newRolloutFloater "NeL Assets PS Database" 550 400
|
||||
addrollout assets_ps_rollout assets_ps_floater rolledUp:false
|
||||
|
||||
|
329
code/nel/tools/3d/plugin_max/scripts/nel_assets_resave.ms
Normal file
329
code/nel/tools/3d/plugin_max/scripts/nel_assets_resave.ms
Normal file
|
@ -0,0 +1,329 @@
|
|||
|
||||
NEL3D_APPDATA_INTERFACE_FILE = 1423062700
|
||||
|
||||
-- Allocate 20 Me for the script
|
||||
heapSize += 15000000
|
||||
|
||||
nlErrorFilename = "W:/database/conversion.log"
|
||||
nlErrorStream = openFile nlErrorFilename mode:"w"
|
||||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Log a message
|
||||
fn nllog message =
|
||||
(
|
||||
if nlErrorStream != undefined then
|
||||
(
|
||||
format "%\n" message to:nlErrorStream
|
||||
flush nlErrorStream
|
||||
)
|
||||
|
||||
-- To the console
|
||||
print message
|
||||
)
|
||||
|
||||
include "nel_utility.ms"
|
||||
|
||||
rollout assets_resave_rollout "Properties"
|
||||
(
|
||||
fn do_it =
|
||||
(
|
||||
max select none
|
||||
|
||||
actionMan.executeAction 0 "40021" -- Selection: Select All
|
||||
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
|
||||
actionMan.executeAction 0 "40807" -- Views: Activate All Maps
|
||||
actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps
|
||||
actionMan.executeAction 0 "40043" -- Selection: Select None
|
||||
|
||||
max views redraw
|
||||
|
||||
return 1
|
||||
)
|
||||
|
||||
-- This script is a base script to include to add multiple functionality to your script
|
||||
|
||||
-- To use this script
|
||||
-- Include it in your script into the rollout at the beginning.
|
||||
-- Implement a do_it function to do the job in your rollout.
|
||||
-- The function should retun -1 if an arror occured, else the count of modification done
|
||||
-- It the function returns <1, the project will not be overwritten
|
||||
|
||||
Group "Running properties"
|
||||
(
|
||||
RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left
|
||||
|
||||
Label DirectoryLabel "Source directory" align:#left
|
||||
EditText Directory "" width:500 align:#left enabled:false
|
||||
Button BrowseDirectory "Browse..." align:#left enabled:false
|
||||
|
||||
CheckBox Recurse "Look in subfolders" checked:true enabled:false
|
||||
CheckBox Test "Test only, do not save" checked:false enabled:false
|
||||
CheckBox BackupFiles "Backup files" checked:false enabled:false
|
||||
CheckBox StopOnError "Stop on error" checked:false enabled:false
|
||||
CheckBox UseTag "Use tag" checked:false enabled:false
|
||||
|
||||
Label ProgressText width:500 align:#left
|
||||
ProgressBar Progress width:500 align:#left
|
||||
|
||||
Button GoButton "Go" width:500 align:#left
|
||||
)
|
||||
|
||||
local countModifications
|
||||
local countErrors
|
||||
local fileModified
|
||||
local fileParsed
|
||||
|
||||
fn UpdateData =
|
||||
(
|
||||
if SourceFiles.state == 2 then
|
||||
isSourceDir = true
|
||||
else
|
||||
isSourceDir = false
|
||||
if Test.checked == true then
|
||||
isTest = true
|
||||
else
|
||||
isTest = false
|
||||
|
||||
Directory.enabled = isSourceDir
|
||||
BrowseDirectory.enabled = isSourceDir
|
||||
Recurse.enabled = isSourceDir
|
||||
Test.enabled = isSourceDir
|
||||
BackupFiles.enabled = isSourceDir and (isTest == false)
|
||||
StopOnError.enabled = isSourceDir
|
||||
UseTag.enabled = isSourceDir
|
||||
)
|
||||
|
||||
on SourceFiles changed state do
|
||||
(
|
||||
UpdateData ()
|
||||
)
|
||||
|
||||
on Test changed state do
|
||||
(
|
||||
UpdateData ()
|
||||
)
|
||||
|
||||
fn call_do_it =
|
||||
(
|
||||
local result
|
||||
|
||||
-- One more project
|
||||
fileParsed = fileParsed + 1
|
||||
|
||||
-- Call it
|
||||
result = do_it ()
|
||||
|
||||
-- Error ?
|
||||
if result < 0 then
|
||||
countErrors = countErrors + 1
|
||||
else
|
||||
countModifications = countModifications + result
|
||||
|
||||
-- Return result
|
||||
return result
|
||||
)
|
||||
|
||||
fn BackupFile file =
|
||||
(
|
||||
local i
|
||||
local newFilename
|
||||
|
||||
i = 0
|
||||
while true do
|
||||
(
|
||||
-- New file name
|
||||
newFilename = file + ".backup_" + (i as string)
|
||||
|
||||
-- File exist ?
|
||||
if (fileExist newFilename) == false then
|
||||
(
|
||||
if (copyFile file newFilename) == false then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
)
|
||||
i = i + 1
|
||||
)
|
||||
)
|
||||
|
||||
fn RecurseFolder currentDirectory =
|
||||
(
|
||||
resetMAXFile #noprompt
|
||||
|
||||
local result
|
||||
local file
|
||||
local files
|
||||
local origAnimStart
|
||||
local origAnimEnd
|
||||
local origFrameRate
|
||||
|
||||
-- Parse files
|
||||
files = getFiles (currentDirectory+"/*.max")
|
||||
|
||||
-- For each files
|
||||
for i = 1 to files.count do
|
||||
(
|
||||
-- File name
|
||||
file = files[i]
|
||||
|
||||
-- Progress bar
|
||||
ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\""
|
||||
Progress.value = i*100/files.count
|
||||
|
||||
if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then
|
||||
(
|
||||
resetMAXFile #noprompt
|
||||
|
||||
nllog("CONVERT " + file)
|
||||
|
||||
-- Open the max project
|
||||
if loadMaxFile file quiet:true == true then
|
||||
(
|
||||
origAnimStart = animationRange.start
|
||||
origAnimEnd = animationRange.end
|
||||
origFrameRate = frameRate
|
||||
|
||||
resetMAXFile #noprompt
|
||||
|
||||
animationRange = interval origAnimStart origAnimEnd
|
||||
frameRate = origFrameRate
|
||||
|
||||
-- Merge the max project
|
||||
if mergeMaxFile file quiet:true == true then
|
||||
(
|
||||
result = call_do_it ()
|
||||
|
||||
-- Error ?
|
||||
if result < 0 then
|
||||
(
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Error in file " + file)
|
||||
)
|
||||
else
|
||||
(
|
||||
-- Save the max project ?
|
||||
if (Test.checked == false) and (result != 0) then
|
||||
(
|
||||
-- Backup the max project ?
|
||||
local ok
|
||||
ok = true
|
||||
if BackupFiles.checked == true then
|
||||
(
|
||||
-- Backup the file
|
||||
if (BackupFile file) == false then
|
||||
(
|
||||
-- Don't save the file because backup has failed
|
||||
ok = false
|
||||
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Can't backup file " + file)
|
||||
|
||||
-- One more error
|
||||
countErrors = countErrors + 1
|
||||
)
|
||||
)
|
||||
|
||||
-- Save the max project ?
|
||||
if ok == true then
|
||||
(
|
||||
if (saveMaxFile file) == true then
|
||||
(
|
||||
fileModified = fileModified + 1
|
||||
)
|
||||
else
|
||||
(
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Can't write file " + file)
|
||||
|
||||
-- One more error
|
||||
countErrors = countErrors + 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
else
|
||||
(
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Can't load file " + file)
|
||||
|
||||
-- One more error
|
||||
countErrors = countErrors + 1
|
||||
)
|
||||
)
|
||||
)
|
||||
else
|
||||
(
|
||||
nllog("SKIP " + file + " by tag")
|
||||
)
|
||||
)
|
||||
|
||||
-- Parse sub directory ?
|
||||
if (Recurse.checked == true) then
|
||||
(
|
||||
local directories
|
||||
|
||||
-- Get the directories
|
||||
directories = getDirectories (currentDirectory+"/*")
|
||||
|
||||
-- For each directories
|
||||
for dir in directories do
|
||||
(
|
||||
RecurseFolder dir
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
on BrowseDirectory pressed do
|
||||
(
|
||||
local dir
|
||||
try
|
||||
(
|
||||
dir = getSavePath () -- caption:"Select the projects directory"
|
||||
if dir != undefined then
|
||||
Directory.text = dir
|
||||
)
|
||||
catch
|
||||
(
|
||||
)
|
||||
)
|
||||
|
||||
on GoButton pressed do
|
||||
(
|
||||
-- Reset count
|
||||
countModifications = 0
|
||||
countErrors = 0
|
||||
fileModified = 0
|
||||
fileParsed = 0
|
||||
|
||||
-- Get files in the shape_source_directory
|
||||
if SourceFiles.state == 2 then
|
||||
(
|
||||
-- Should warning user ?
|
||||
if (SourceFiles.state == 2) and (Test.checked == false) then
|
||||
(
|
||||
-- Warning !
|
||||
if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then
|
||||
RecurseFolder (adjustPathStringForScript Directory.text)
|
||||
)
|
||||
else
|
||||
(
|
||||
RecurseFolder (adjustPathStringForScript Directory.text)
|
||||
)
|
||||
)
|
||||
else
|
||||
(
|
||||
-- Just compute the current project
|
||||
call_do_it ()
|
||||
)
|
||||
|
||||
-- Show errors
|
||||
ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)."
|
||||
Progress.value = 100
|
||||
)
|
||||
)
|
||||
|
||||
assets_resave_floater = newRolloutFloater "NeL Assets Resave Database" 550 874
|
||||
addrollout assets_resave_rollout assets_resave_floater rolledUp:false
|
||||
|
316
code/nel/tools/3d/plugin_max/scripts/nel_assets_resave_hard.ms
Normal file
316
code/nel/tools/3d/plugin_max/scripts/nel_assets_resave_hard.ms
Normal file
|
@ -0,0 +1,316 @@
|
|||
|
||||
NEL3D_APPDATA_INTERFACE_FILE = 1423062700
|
||||
|
||||
-- Allocate 20 Me for the script
|
||||
heapSize += 15000000
|
||||
|
||||
nlErrorFilename = "W:/database/conversion.log"
|
||||
nlErrorStream = openFile nlErrorFilename mode:"w"
|
||||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Log a message
|
||||
fn nllog message =
|
||||
(
|
||||
if nlErrorStream != undefined then
|
||||
(
|
||||
format "%\n" message to:nlErrorStream
|
||||
flush nlErrorStream
|
||||
)
|
||||
|
||||
-- To the console
|
||||
print message
|
||||
)
|
||||
|
||||
include "nel_utility.ms"
|
||||
|
||||
rollout assets_resave_rollout "Properties"
|
||||
(
|
||||
fn do_it =
|
||||
(
|
||||
max select none
|
||||
|
||||
actionMan.executeAction 0 "40021" -- Selection: Select All
|
||||
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
|
||||
actionMan.executeAction 0 "40807" -- Views: Activate All Maps
|
||||
actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps
|
||||
actionMan.executeAction 0 "40043" -- Selection: Select None
|
||||
|
||||
max views redraw
|
||||
|
||||
return 1
|
||||
)
|
||||
|
||||
-- This script is a base script to include to add multiple functionality to your script
|
||||
|
||||
-- To use this script
|
||||
-- Include it in your script into the rollout at the beginning.
|
||||
-- Implement a do_it function to do the job in your rollout.
|
||||
-- The function should retun -1 if an arror occured, else the count of modification done
|
||||
-- It the function returns <1, the project will not be overwritten
|
||||
|
||||
Group "Running properties"
|
||||
(
|
||||
RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left
|
||||
|
||||
Label DirectoryLabel "Source directory" align:#left
|
||||
EditText Directory "" width:500 align:#left enabled:false
|
||||
Button BrowseDirectory "Browse..." align:#left enabled:false
|
||||
|
||||
CheckBox Recurse "Look in subfolders" checked:true enabled:false
|
||||
CheckBox Test "Test only, do not save" checked:false enabled:false
|
||||
CheckBox BackupFiles "Backup files" checked:false enabled:false
|
||||
CheckBox StopOnError "Stop on error" checked:false enabled:false
|
||||
CheckBox UseTag "Use tag" checked:false enabled:false
|
||||
|
||||
Label ProgressText width:500 align:#left
|
||||
ProgressBar Progress width:500 align:#left
|
||||
|
||||
Button GoButton "Go" width:500 align:#left
|
||||
)
|
||||
|
||||
local countModifications
|
||||
local countErrors
|
||||
local fileModified
|
||||
local fileParsed
|
||||
|
||||
fn UpdateData =
|
||||
(
|
||||
if SourceFiles.state == 2 then
|
||||
isSourceDir = true
|
||||
else
|
||||
isSourceDir = false
|
||||
if Test.checked == true then
|
||||
isTest = true
|
||||
else
|
||||
isTest = false
|
||||
|
||||
Directory.enabled = isSourceDir
|
||||
BrowseDirectory.enabled = isSourceDir
|
||||
Recurse.enabled = isSourceDir
|
||||
Test.enabled = isSourceDir
|
||||
BackupFiles.enabled = isSourceDir and (isTest == false)
|
||||
StopOnError.enabled = isSourceDir
|
||||
UseTag.enabled = isSourceDir
|
||||
)
|
||||
|
||||
on SourceFiles changed state do
|
||||
(
|
||||
UpdateData ()
|
||||
)
|
||||
|
||||
on Test changed state do
|
||||
(
|
||||
UpdateData ()
|
||||
)
|
||||
|
||||
fn call_do_it =
|
||||
(
|
||||
local result
|
||||
|
||||
-- One more project
|
||||
fileParsed = fileParsed + 1
|
||||
|
||||
-- Call it
|
||||
result = do_it ()
|
||||
|
||||
-- Error ?
|
||||
if result < 0 then
|
||||
countErrors = countErrors + 1
|
||||
else
|
||||
countModifications = countModifications + result
|
||||
|
||||
-- Return result
|
||||
return result
|
||||
)
|
||||
|
||||
fn BackupFile file =
|
||||
(
|
||||
local i
|
||||
local newFilename
|
||||
|
||||
i = 0
|
||||
while true do
|
||||
(
|
||||
-- New file name
|
||||
newFilename = file + ".backup_" + (i as string)
|
||||
|
||||
-- File exist ?
|
||||
if (fileExist newFilename) == false then
|
||||
(
|
||||
if (copyFile file newFilename) == false then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
)
|
||||
i = i + 1
|
||||
)
|
||||
)
|
||||
|
||||
fn RecurseFolder currentDirectory =
|
||||
(
|
||||
resetMAXFile #noprompt
|
||||
|
||||
local result
|
||||
local file
|
||||
local files
|
||||
local origAnimStart
|
||||
local origAnimEnd
|
||||
local origFrameRate
|
||||
|
||||
-- Parse files
|
||||
files = getFiles (currentDirectory+"/*.max")
|
||||
|
||||
-- For each files
|
||||
for i = 1 to files.count do
|
||||
(
|
||||
-- File name
|
||||
file = files[i]
|
||||
|
||||
-- Progress bar
|
||||
ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\""
|
||||
Progress.value = i*100/files.count
|
||||
|
||||
if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then
|
||||
(
|
||||
resetMAXFile #noprompt
|
||||
|
||||
nllog("CONVERT " + file)
|
||||
|
||||
-- Merge the max project
|
||||
if mergeMaxFile file quiet:true == true then
|
||||
(
|
||||
result = call_do_it ()
|
||||
|
||||
-- Error ?
|
||||
if result < 0 then
|
||||
(
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Error in file " + file)
|
||||
)
|
||||
else
|
||||
(
|
||||
-- Save the max project ?
|
||||
if (Test.checked == false) and (result != 0) then
|
||||
(
|
||||
-- Backup the max project ?
|
||||
local ok
|
||||
ok = true
|
||||
if BackupFiles.checked == true then
|
||||
(
|
||||
-- Backup the file
|
||||
if (BackupFile file) == false then
|
||||
(
|
||||
-- Don't save the file because backup has failed
|
||||
ok = false
|
||||
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Can't backup file " + file)
|
||||
|
||||
-- One more error
|
||||
countErrors = countErrors + 1
|
||||
)
|
||||
)
|
||||
|
||||
-- Save the max project ?
|
||||
if ok == true then
|
||||
(
|
||||
if (saveMaxFile file) == true then
|
||||
(
|
||||
fileModified = fileModified + 1
|
||||
)
|
||||
else
|
||||
(
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Can't write file " + file)
|
||||
|
||||
-- One more error
|
||||
countErrors = countErrors + 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
else
|
||||
(
|
||||
if StopOnError.checked == true then
|
||||
Messagebox ("Can't load file " + file)
|
||||
|
||||
-- One more error
|
||||
countErrors = countErrors + 1
|
||||
)
|
||||
)
|
||||
else
|
||||
(
|
||||
nllog("SKIP " + file + " by tag")
|
||||
)
|
||||
)
|
||||
|
||||
-- Parse sub directory ?
|
||||
if (Recurse.checked == true) then
|
||||
(
|
||||
local directories
|
||||
|
||||
-- Get the directories
|
||||
directories = getDirectories (currentDirectory+"/*")
|
||||
|
||||
-- For each directories
|
||||
for dir in directories do
|
||||
(
|
||||
RecurseFolder dir
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
on BrowseDirectory pressed do
|
||||
(
|
||||
local dir
|
||||
try
|
||||
(
|
||||
dir = getSavePath () -- caption:"Select the projects directory"
|
||||
if dir != undefined then
|
||||
Directory.text = dir
|
||||
)
|
||||
catch
|
||||
(
|
||||
)
|
||||
)
|
||||
|
||||
on GoButton pressed do
|
||||
(
|
||||
-- Reset count
|
||||
countModifications = 0
|
||||
countErrors = 0
|
||||
fileModified = 0
|
||||
fileParsed = 0
|
||||
|
||||
-- Get files in the shape_source_directory
|
||||
if SourceFiles.state == 2 then
|
||||
(
|
||||
-- Should warning user ?
|
||||
if (SourceFiles.state == 2) and (Test.checked == false) then
|
||||
(
|
||||
-- Warning !
|
||||
if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then
|
||||
RecurseFolder (adjustPathStringForScript Directory.text)
|
||||
)
|
||||
else
|
||||
(
|
||||
RecurseFolder (adjustPathStringForScript Directory.text)
|
||||
)
|
||||
)
|
||||
else
|
||||
(
|
||||
-- Just compute the current project
|
||||
call_do_it ()
|
||||
)
|
||||
|
||||
-- Show errors
|
||||
ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)."
|
||||
Progress.value = 100
|
||||
)
|
||||
)
|
||||
|
||||
assets_resave_floater = newRolloutFloater "NeL Assets Resave Database Hard" 550 874
|
||||
addrollout assets_resave_rollout assets_resave_floater rolledUp:false
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
#include "nel/misc/system_utils.h"
|
||||
// 3D Interface.
|
||||
#include "nel/3d/bloom_effect.h"
|
||||
#include "nel/3d/fxaa.h"
|
||||
#include "nel/3d/fasthls_modifier.h"
|
||||
#include "nel/3d/particle_system_manager.h"
|
||||
#include "nel/3d/particle_system.h"
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "nel/misc/file.h"
|
||||
|
||||
// Game share
|
||||
#include "server_share/bmp4image.h"
|
||||
#include "game_share/bmp4image.h"
|
||||
|
||||
// AI share
|
||||
#include "ai_share/world_map.h"
|
||||
|
|
Loading…
Reference in a new issue