-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use new format of confi - export will try to auto detect original texture suffix and apply it. - Add option for disable name prefix - use some std funcs to replace traditional C style code.
- Loading branch information
Showing
14 changed files
with
323 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "buffer_helper.h" | ||
|
||
namespace buffer_helper { | ||
|
||
char* global_buffer; | ||
char* export_buffer; | ||
char* misc_buffer; | ||
char* misc_buffer2; | ||
|
||
BOOL InitBuffer() { | ||
global_buffer = (char*)malloc(BUFFER_SIZE * sizeof(char)); | ||
export_buffer = (char*)malloc(BUFFER_SIZE * sizeof(char)); | ||
misc_buffer = (char*)malloc(BUFFER_SIZE * sizeof(char)); | ||
misc_buffer2 = (char*)malloc(BUFFER_SIZE * sizeof(char)); | ||
|
||
return (global_buffer && export_buffer && misc_buffer && misc_buffer2); | ||
} | ||
void DisposeBuffer() { | ||
#define safe_free(a) if(a)free(a); | ||
safe_free(global_buffer); | ||
safe_free(export_buffer); | ||
safe_free(misc_buffer); | ||
safe_free(misc_buffer2); | ||
#undef safe_free | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#if !defined(_YYCDLL_BUFFER_HELPER_H__IMPORTED_) | ||
#define _YYCDLL_BUFFER_HELPER_H__IMPORTED_ | ||
|
||
#include "stdafx.h" | ||
#define BUFFER_SIZE 65526 | ||
|
||
namespace buffer_helper { | ||
|
||
extern char* global_buffer; | ||
extern char* export_buffer; | ||
extern char* misc_buffer; | ||
extern char* misc_buffer2; | ||
|
||
BOOL InitBuffer(); | ||
void DisposeBuffer(); | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#include "stdafx.h" | ||
#include "config_manager.h" | ||
#include "buffer_helper.h" | ||
#include <filesystem> | ||
|
||
#define APP_VERSION 130 | ||
|
||
extern PluginInterface* s_Plugininterface; | ||
|
||
void config_manager::GetConfigFilePath(char* buffer) { | ||
std::filesystem::path file(s_Plugininterface->GetVirtoolsDirectory()); | ||
file /= "vtobjplugin.cfg"; | ||
strcpy(buffer, file.string().c_str()); | ||
} | ||
|
||
void config_manager::LoadConfig(ExportConfig* cfg) { | ||
GetConfigFilePath(buffer_helper::global_buffer); | ||
|
||
// init necessary variable before goto | ||
std::string temp_str; | ||
int temp_int = 0; | ||
int gotten_version; | ||
|
||
FILE* f = fopen(buffer_helper::global_buffer, "rb"); | ||
if (f == NULL) goto needInitCfg; | ||
|
||
//read config | ||
#define readint(target,conv) fread(&target, sizeof(int), 1, f); | ||
#define readstr(target) fread(&temp_int, sizeof(size_t), 1, f);fread(buffer_helper::global_buffer, sizeof(char), temp_int, f);buffer_helper::global_buffer[temp_int]='\0';target=buffer_helper::global_buffer; | ||
|
||
//check version | ||
readint(gotten_version); | ||
if (gotten_version != APP_VERSION) { | ||
fclose(f); | ||
goto needInitCfg; | ||
} | ||
|
||
readint(cfg->export_mode, ExportMode); | ||
cfg->selected_item = 0; | ||
readint(cfg->file_mode, FileMode); | ||
readstr(cfg->export_folder); | ||
readint(cfg->omit_transform, BOOL); | ||
readint(cfg->right_hand, BOOL); | ||
readint(cfg->name_prefix, BOOL); | ||
readint(cfg->reposition_3dsmax, BOOL); | ||
readint(cfg->reposition_blender, BOOL); | ||
readint(cfg->export_mtl, BOOL); | ||
readint(cfg->export_texture, BOOL); | ||
readint(cfg->copy_texture, BOOL); | ||
readint(cfg->custom_texture_format, BOOL); | ||
readstr(cfg->texture_format); | ||
|
||
#undef readint | ||
#undef readstr | ||
|
||
fclose(f); | ||
return; | ||
|
||
needInitCfg: | ||
//no config, set default and save it. | ||
cfg->export_mode = EXPORTMODE_ALL; | ||
cfg->selected_item = 0; | ||
cfg->file_mode = FILEMODE_MULTIFILE; | ||
cfg->export_folder = ""; | ||
cfg->omit_transform = TRUE; | ||
cfg->right_hand = TRUE; | ||
cfg->name_prefix = TRUE; | ||
cfg->reposition_3dsmax = FALSE; | ||
cfg->reposition_blender = FALSE; | ||
cfg->export_mtl = TRUE; | ||
cfg->export_texture = TRUE; | ||
cfg->copy_texture = FALSE; | ||
cfg->custom_texture_format = TRUE; | ||
cfg->texture_format = "bmp"; | ||
|
||
SaveConfig(cfg); | ||
return; | ||
} | ||
|
||
void config_manager::SaveConfig(ExportConfig* cfg) { | ||
GetConfigFilePath(buffer_helper::global_buffer); | ||
|
||
FILE* f = fopen(buffer_helper::global_buffer, "wb"); | ||
assert(f != NULL); | ||
|
||
const char* temp_str = NULL; | ||
int temp_int = 0; | ||
#define writeconstint(target) temp_int=target;fwrite(&temp_int, sizeof(int), 1, f); | ||
#define writeint(target) fwrite(&target, sizeof(int), 1, f); | ||
#define writestr(target) temp_str=target;temp_int=strlen(temp_str);fwrite(&temp_int, sizeof(size_t), 1, f);fwrite(temp_str, sizeof(char), temp_int, f); | ||
|
||
writeconstint(APP_VERSION); | ||
writeint(cfg->export_mode); | ||
writeint(cfg->file_mode); | ||
writestr(cfg->export_folder.c_str()); | ||
writeint(cfg->omit_transform); | ||
writeint(cfg->right_hand); | ||
writeint(cfg->name_prefix); | ||
writeint(cfg->reposition_3dsmax); | ||
writeint(cfg->reposition_blender); | ||
writeint(cfg->export_mtl); | ||
writeint(cfg->export_texture); | ||
writeint(cfg->copy_texture); | ||
writeint(cfg->custom_texture_format); | ||
writestr(cfg->texture_format.c_str()); | ||
|
||
#undef writeconstint | ||
#undef writeint | ||
#undef writestr | ||
|
||
fclose(f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#if !defined(_YYCDLL_CONFIG_MANAGER_H__IMPORTED_) | ||
#define _YYCDLL_CONFIG_MANAGER_H__IMPORTED_ | ||
|
||
#include "obj_export.h" | ||
|
||
namespace config_manager { | ||
|
||
void GetConfigFilePath(char* buffer); | ||
void SaveConfig(ExportConfig* cfg); | ||
void LoadConfig(ExportConfig* cfg); | ||
|
||
} | ||
|
||
#endif |
Oops, something went wrong.