mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-18 09:35:48 +00:00
source code checkin
This commit is contained in:
parent
5f8fb2c825
commit
7e57b72e35
675 changed files with 168433 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class DifficultyOffsetValueConverter : IValueConverter
|
||||
{
|
||||
public const double MinValue = 50;
|
||||
public const double MaxValue = 400;
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
double scaledValue = System.Convert.ToDouble(value); ;
|
||||
var sliderValue = MinValue + (scaledValue * (MaxValue - MinValue));
|
||||
sliderValue = Math.Max(MinValue, sliderValue);
|
||||
return sliderValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var sliderValue = System.Convert.ToDouble(value);
|
||||
sliderValue = (double)sliderValue - (double)MinValue;
|
||||
var scaledValue = sliderValue / (double)(MaxValue - MinValue);
|
||||
scaledValue = Math.Max(0.01, scaledValue);
|
||||
return scaledValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class DinoNameValueConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var strVal = value as string;
|
||||
return strVal.Substring(0, strVal.IndexOf('_'));
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class EngramClassNameToDisplayNameConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return Convert(value);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static object Convert(object value)
|
||||
{
|
||||
try
|
||||
{
|
||||
var strVal = value as string;
|
||||
var name = GameData.FriendlyNameForClass(strVal);
|
||||
if (!string.IsNullOrWhiteSpace(name) && !name.Equals(strVal))
|
||||
return name;
|
||||
|
||||
var firstIndex = strVal.IndexOf('_') + 1;
|
||||
var length = strVal.LastIndexOf('_') - firstIndex;
|
||||
return strVal.Substring(firstIndex, length);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using WPFSharp.Globalizer;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class EnumDescriptionTypeConverter : EnumConverter
|
||||
{
|
||||
public EnumDescriptionTypeConverter(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
var strType = value.GetType().Name;
|
||||
var strVal = value.ToString();
|
||||
|
||||
return GlobalizedApplication.Instance.GetResourceString($"{strType}_{strVal}") ?? strVal;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
using ServerManagerTool.Utils;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class ExtinctionEventDateConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double scaledValue = System.Convert.ToInt32(value);
|
||||
|
||||
if (scaledValue <= 0)
|
||||
return string.Empty;
|
||||
|
||||
var displayValue = ModUtils.UnixTimeStampToDateTime(scaledValue);
|
||||
return displayValue.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class ExtinctionEventTimeIntervalConverter : IValueConverter
|
||||
{
|
||||
public const int MIN_VALUE = 1;
|
||||
public const int MAX_VALUE = 1000;
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double scaledValue = System.Convert.ToInt32(value);
|
||||
|
||||
var sliderValue = (int)TimeSpan.FromSeconds(scaledValue).TotalDays;
|
||||
sliderValue = Math.Max(MIN_VALUE, sliderValue);
|
||||
sliderValue = Math.Min(MAX_VALUE, sliderValue);
|
||||
return sliderValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var sliderValue = System.Convert.ToInt32(value);
|
||||
sliderValue = Math.Max(MIN_VALUE, sliderValue);
|
||||
sliderValue = Math.Min(MAX_VALUE, sliderValue);
|
||||
|
||||
var scaledValue = (int)TimeSpan.FromDays(sliderValue).TotalSeconds;
|
||||
return scaledValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
|
||||
public class PlayerLevelIndexToDisplayLevelConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return (int)value + 2;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class DinoLevelIndexToDisplayLevelConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return (int)value + 1;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
using ServerManagerTool.Utils;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using WPFSharp.Globalizer;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class MapNameValueConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
try
|
||||
{
|
||||
var valueString = value as string;
|
||||
if (valueString == null)
|
||||
return string.Empty;
|
||||
|
||||
var name = GlobalizedApplication.Instance.GetResourceString(valueString);
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
return name;
|
||||
|
||||
var mapName = ModUtils.GetMapName(valueString);
|
||||
|
||||
// check if the name is stored in the globalization file
|
||||
name = GlobalizedApplication.Instance.GetResourceString(mapName);
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
return name;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(mapName))
|
||||
return mapName;
|
||||
|
||||
return valueString;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return value ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class OfficialDifficultyValueConverter : IValueConverter
|
||||
{
|
||||
public const double DINO_LEVELS = 30.0f;
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var scaledValue = System.Convert.ToDouble(value);
|
||||
scaledValue = Math.Max(1.0, scaledValue);
|
||||
|
||||
var sliderValue = scaledValue * DINO_LEVELS;
|
||||
sliderValue = Math.Max(DINO_LEVELS, sliderValue);
|
||||
|
||||
return (int)sliderValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var sliderValue = System.Convert.ToDouble(value);
|
||||
sliderValue = Math.Max(DINO_LEVELS, sliderValue);
|
||||
|
||||
var scaledValue = sliderValue / DINO_LEVELS;
|
||||
scaledValue = Math.Max(1.0, scaledValue);
|
||||
|
||||
return scaledValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class PrimalItemClassNameToDisplayNameConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return Convert(value);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static object Convert(object value)
|
||||
{
|
||||
try
|
||||
{
|
||||
var strVal = value as string;
|
||||
var name = GameData.FriendlyNameForClass(strVal);
|
||||
if (!string.IsNullOrWhiteSpace(name) && !name.Equals(strVal))
|
||||
return name;
|
||||
|
||||
var firstIndex = strVal.IndexOf('_');
|
||||
var lastIndex = strVal.LastIndexOf('_');
|
||||
return strVal.Substring(firstIndex + 1, lastIndex - firstIndex - 1).Replace('_', ' ');
|
||||
}
|
||||
catch
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class ResourceNameValueConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return Convert(value);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static object Convert(object value)
|
||||
{
|
||||
try
|
||||
{
|
||||
var strVal = value as string;
|
||||
var name = GameData.FriendlyNameForClass(strVal);
|
||||
if (!string.IsNullOrWhiteSpace(name) && !name.Equals(strVal))
|
||||
return name;
|
||||
|
||||
var firstIndex = strVal.IndexOf('_');
|
||||
var lastIndex = strVal.LastIndexOf('_');
|
||||
return strVal.Substring(firstIndex + 1, lastIndex - firstIndex - 1).Replace('_', ' ');
|
||||
}
|
||||
catch
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class SupplyCrateClassNameToDisplayNameConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return Convert(value);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static object Convert(object value)
|
||||
{
|
||||
try
|
||||
{
|
||||
var strVal = value as string;
|
||||
var name = GameData.FriendlyNameForClass(strVal);
|
||||
if (!string.IsNullOrWhiteSpace(name) && !name.Equals(strVal))
|
||||
return name;
|
||||
|
||||
var firstIndex = strVal.IndexOf('_');
|
||||
var lastIndex = strVal.LastIndexOf('_');
|
||||
return strVal.Substring(0, lastIndex - firstIndex - 1).Replace('_', ' ');
|
||||
}
|
||||
catch
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class TributeExpirationConverter : IValueConverter
|
||||
{
|
||||
public const int MIN_VALUE = 1;
|
||||
public const int MAX_VALUE = 20000;
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double scaledValue = System.Convert.ToInt32(value);
|
||||
|
||||
var sliderValue = (int)TimeSpan.FromSeconds(scaledValue).TotalMinutes;
|
||||
sliderValue = Math.Max(MIN_VALUE, sliderValue);
|
||||
sliderValue = Math.Min(MAX_VALUE, sliderValue);
|
||||
return sliderValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var sliderValue = System.Convert.ToInt32(value);
|
||||
sliderValue = Math.Max(MIN_VALUE, sliderValue);
|
||||
sliderValue = Math.Min(MAX_VALUE, sliderValue);
|
||||
|
||||
var scaledValue = (int)TimeSpan.FromMinutes(sliderValue).TotalSeconds;
|
||||
return scaledValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue