Skip to content

Commit

Permalink
small feature requests (WolvenKit#184)
Browse files Browse the repository at this point in the history
* bugfixes

- added ELightChannel enum
- fixed relative path copying in ModExplorer
- fixed a bug where files in frmScriptEditor would be saved in utf8 instead of utf16LE
- fixed a bug where dlc textures would get imported as bundle in the importUtility

* pack and launch fixes

- fixed launching the game when packing is cancelled

* dumb more hotkeys

- F5 : pack and install mod
- Ctrl+F5: pack and install mod, launch game

* wkit small feature requests

- added an option to disable the welcome form
- fixed a bug with xbm image preview
- added hotkeys to close and reopen tabs (ctrl + W, ctrl + shift + T)
- updated the main and welcome forms abit
- added more bulk edit options

* frm Welcome redesign

frm Welcome redesign

* persist toolstrip locations

- added checks for when no mod is loaded
- persist toolstrip locations
  • Loading branch information
rfuzzo authored Jun 10, 2020
1 parent 0fe6b5b commit a9d81be
Show file tree
Hide file tree
Showing 14 changed files with 1,879 additions and 1,419 deletions.
1 change: 1 addition & 0 deletions WolvenKit.App/Controllers/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static string ConfigurationPath
public string InitialExportDirectory { get; set; }

public EUncookExtension UncookExtension { get; set; }
public bool IsWelcomeFormDisabled { get; set; }


[XmlIgnore]
Expand Down
9 changes: 3 additions & 6 deletions WolvenKit.App/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ public class MainViewModel : ViewModel
private string _title;
public virtual string Title
{
get
{
return _title;
}
get => _title;
set
{
if (_title != value)
Expand All @@ -37,12 +34,12 @@ public virtual string Title
}
#endregion



#endregion

#region Fields

#endregion


Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/Basic/CString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class CString : CVariable
public CString(CR2WFile cr2w)
: base(cr2w)
{
Type = "String";
}

[DataMember]
Expand Down
8 changes: 4 additions & 4 deletions WolvenKit.Cache/ImageUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ public static byte[] Xbm2DdsBytes(CBitmapTexture xbm)
if (xbm == null)
return null;

int residentMipIndex = xbm.GetVariableByName("ResidentMipIndex") == null ? 0 : (int)((CUInt8)xbm.GetVariableByName("ResidentMipIndex")).val;
int residentMipIndex = xbm.GetVariableByName("residentMipIndex") == null ? 0 : (int)((CUInt8)xbm.GetVariableByName("residentMipIndex")).val;
byte[] bytesource;
// handle cooked xbms
if (xbm.GetVariableByName("SourceData") == null)
if (xbm.GetVariableByName("sourceData") == null)
{
bytesource = xbm.Residentmip.Bytes;
}
Expand Down Expand Up @@ -229,11 +229,11 @@ private static DDSMetadata Xbm2Ddsheader(CBitmapTexture xbm)
{
try
{
int residentMipIndex = xbm.GetVariableByName("ResidentMipIndex") == null ? 0 : (int)((CUInt8)xbm.GetVariableByName("ResidentMipIndex")).val;
int residentMipIndex = xbm.GetVariableByName("residentMipIndex") == null ? 0 : (int)((CUInt8)xbm.GetVariableByName("residentMipIndex")).val;

int mipcount;
// handle cooked xbms
if (xbm.GetVariableByName("SourceData") == null)
if (xbm.GetVariableByName("sourceData") == null)
{
mipcount = xbm.Mipdata.elements.Count - residentMipIndex;
}
Expand Down
107 changes: 94 additions & 13 deletions WolvenKit/Forms/frmConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,81 @@ bool TryEditVariable(CVariable v, string parentname)
// edit value
try
{
v.SetValue(opts.val);
AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal);
// check option
switch (opts.option)
{
case "*":
{
switch (opts.type)
{
case "Uint64": ((CUInt64)v).val *= ulong.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int64": ((CInt64)v).val *= long.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Uint32": ((CUInt32)v).val *= uint.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int32": ((CInt32)v).val *= int.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Uint16": ((CUInt16)v).val *= ushort.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int16": ((CInt16)v).val *= short.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Uint8": ((CUInt8)v).val *= byte.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int8": ((CInt8)v).val *= sbyte.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
default: break;
}
break;
}
case "/":
{
switch (opts.type)
{
case "Uint64": ((CUInt64)v).val /= ulong.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int64": ((CInt64)v).val /= long.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Uint32": ((CUInt32)v).val /= uint.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int32": ((CInt32)v).val /= int.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Uint16": ((CUInt16)v).val /= ushort.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int16": ((CInt16)v).val /= short.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Uint8": ((CUInt8)v).val /= byte.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int8": ((CInt8)v).val /= sbyte.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
default: break;
}
break;
}
case "+":
{
switch (opts.type)
{
case "Uint64": ((CUInt64)v).val += ulong.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int64": ((CInt64)v).val += long.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Uint32": ((CUInt32)v).val += uint.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int32": ((CInt32)v).val += int.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Uint16": ((CUInt16)v).val += ushort.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int16": ((CInt16)v).val += short.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Uint8": ((CUInt8)v).val += byte.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "Int8": ((CInt8)v).val += sbyte.Parse(opts.val); AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal); break;
case "String": ((CString)v).val += opts.val; break;

default: break;
}
break;
}
case "-":
{
switch (opts.type)
{
case "Uint64": ((CUInt64)v).val -= ulong.Parse(opts.val); break;
case "Int64": ((CInt64)v).val -= long.Parse(opts.val); break;
case "Uint32": ((CUInt32)v).val -= uint.Parse(opts.val); break;
case "Int32": ((CInt32)v).val -= int.Parse(opts.val); break;
case "Uint16": ((CUInt16)v).val -= ushort.Parse(opts.val); break;
case "Int16": ((CInt16)v).val -= short.Parse(opts.val); break;
case "Uint8": ((CUInt8)v).val -= byte.Parse(opts.val); break;
case "Int8": ((CInt8)v).val -= sbyte.Parse(opts.val); break;

default: break;
}
break;
}
default:
v.SetValue(opts.val);
AddTextStatic($"Succesfully edited a variable in {parentname}: {path}.\r\n", Logtype.Normal);
break;
}
return true;
}
catch (Exception ex)
Expand All @@ -260,45 +333,53 @@ bool TryEditVariable(CVariable v, string parentname)
}
}

[Verb("bulkedit", HelpText = "Bulk edit cr2w files. " +
[Verb("bulkedit", HelpText = "Bulk edit cr2w files. \n\r" +
"Example use: -v 9999 -n autohidedistance -c CMesh -t Uint16 --err=true --exc=0,1029")]
class BulkEditOptions
{
[Option('n', HelpText = "Specify the variable name. " +
// Required
[Option('n', HelpText = "Specify the variable name. \n\r" +
"Example: -n autohidedistance", Required = true)]
public string var { get; set; }

// Required
[Option('v', HelpText = "Specify the new variable value. " +
[Option('v', HelpText = "Specify the new variable value. \n\r" +
"Example: -v 9999", Required = true)]
public string val { get; set; }

// Optional string
[Option('e', HelpText = "Specify the file extension to edit. " +
[Option('e', HelpText = "Specify the file extension to edit. \n\r" +
"Example: -e w2mesh", Required = false)]
public string ext { get; set; }

[Option('c', HelpText = "Specify the chunk name. Example: -c CMesh", Required = false)]
[Option('c', HelpText = "Specify the chunk name. \n\r" +
"Example: -c CMesh", Required = false)]
public string chunk { get; set; }

[Option('t', HelpText = "Specify the variable type. " +
"Available types are Bool, Uint64, Int64, Uint32, Int32, Uint16, Int16, Uint8, Int8" +
[Option('t', HelpText = "Specify the variable type. \n\r" +
"Available types are Bool, Uint64, Int64, Uint32, Int32, Uint16, Int16, Uint8, Int8\n\r" +
"Example: -t Uint16"
, Required = false)]
public string type { get; set; }

[Option('o', HelpText = "Specify the option type. Default is replace. This option requires a valid type to be set with -t !!\n\r" +
"Available types are Multiplication (*), Division (/), Addition (+), Subtraction (-),\n\r" +
"Example: -o + -t Uint16\n\r" +
"Example: -o / -t Int32"
, Required = false)]
public string option { get; set; }

//[Option('p', HelpText = "Specify the parent name of the variable you want to edit.", Required = false)]
//public string parent { get; set; }

[Option(HelpText = "Verbose errors. " +
[Option(HelpText = "Verbose errors.\n\r" +
"Example: --err=true", Required = false)]
public string err { get; set; }

// Optional lists
[Option(Separator = ',', HelpText = "Exclude the following values. " +
[Option(Separator = ',', HelpText = "Exclude the following values.\n\r" +
"Example: --exc=0,64,1028,2053", Required = false)]
public IEnumerable<string> exc { get; set; }
[Option(Separator = ',', HelpText = "Include only the following values. " +
[Option(Separator = ',', HelpText = "Include only the following values.\n\r" +
"Example: --inc=0,32,64", Required = false)]
public IEnumerable<string> inc { get; set; }
}
Expand Down
Loading

0 comments on commit a9d81be

Please sign in to comment.