Here are the examples of the csharp api System.Collections.Generic.List.Add(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
24573 Examples
19
Source : GridAcademy.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void SetEnvironment()
{
trueAgent = GameObject.Find("trueAgent");
List<string> playersList = new List<string>();
actorObjs = new List<GameObject>();
for (int i = 0; i < (int)resetParameters["numObstacles"]; i++)
{
playersList.Add("pit");
}
playersList.Add("agent");
for (int i = 0; i < (int)resetParameters["numGoals"]; i++)
{
playersList.Add("goal");
}
players = playersList.ToArray();
Camera cam = GameObject.Find("Main Camera").GetComponent<Camera>();
cam.transform.position = new Vector3(-((int)resetParameters["gridSize"] - 1) / 2f, (int)resetParameters["gridSize"] * 1.25f, -((int)resetParameters["gridSize"] - 1) / 2f);
cam.orthographicSize = ((int)resetParameters["gridSize"] + 5f) / 2f;
GameObject.Find("Plane").transform.localScale = new Vector3((int)resetParameters["gridSize"] / 10.0f, 1f, (int)resetParameters["gridSize"] / 10.0f);
GameObject.Find("Plane").transform.position = new Vector3(((int)resetParameters["gridSize"] - 1) / 2f, -0.5f, ((int)resetParameters["gridSize"] - 1) / 2f);
GameObject.Find("sN").transform.localScale = new Vector3(1, 1, (int)resetParameters["gridSize"] + 2);
GameObject.Find("sS").transform.localScale = new Vector3(1, 1, (int)resetParameters["gridSize"] + 2);
GameObject.Find("sN").transform.position = new Vector3(((int)resetParameters["gridSize"] - 1) / 2f, 0.0f, (int)resetParameters["gridSize"]);
GameObject.Find("sS").transform.position = new Vector3(((int)resetParameters["gridSize"] - 1) / 2f, 0.0f, -1);
GameObject.Find("sE").transform.localScale = new Vector3(1, 1, (int)resetParameters["gridSize"] + 2);
GameObject.Find("sW").transform.localScale = new Vector3(1, 1, (int)resetParameters["gridSize"] + 2);
GameObject.Find("sE").transform.position = new Vector3((int)resetParameters["gridSize"], 0.0f, ((int)resetParameters["gridSize"] - 1) / 2f);
GameObject.Find("sW").transform.position = new Vector3(-1, 0.0f, ((int)resetParameters["gridSize"] - 1) / 2f);
Camera aCam = GameObject.Find("agentCam").GetComponent<Camera>();
aCam.orthographicSize = ((int)resetParameters["gridSize"]) / 2f;
aCam.transform.position = new Vector3(((int)resetParameters["gridSize"] - 1) / 2f, (int)resetParameters["gridSize"] + 1f, ((int)resetParameters["gridSize"] - 1) / 2f);
}
19
Source : DownloadingAssetsList.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void Update()
{
List<Downloadingreplacedereplacedem> finishedItems = new List<Downloadingreplacedereplacedem>();
if (downloadingItems.Count > 0)
{
areDownloadedItemsReady = false;
List<string> finishedBundles = new List<string>();
foreach (Downloadingreplacedereplacedem dli in downloadingItems)
{
bool canProcessBatch = true;
dli.UpdateProgress();
string error = "";
if (finishedBundles.Contains(dli.containingBundle))
{
if (dli.flagForRemoval == false)
{
dli.flagForRemoval = true;
}
else
{
if (dli.isBeingRemoved)
canProcessBatch = false;
}
}
else if (replacedetBundleManager.GetLoadedreplacedetBundle(dli.containingBundle, out error) != null)
{
finishedBundles.Add(dli.containingBundle);
if (dli.flagForRemoval == false)
{
dli.flagForRemoval = true;
}
else
{
if (dli.isBeingRemoved)
canProcessBatch = false;
}
}
else
{
canProcessBatch = false;
}
if (canProcessBatch)
{
finishedItems.Add(dli);
}
}
}
//send the finished downloads to be processed
if (finishedItems.Count > 0)
{
DynamicreplacedetLoader.Instance.StartCoroutine(RemoveDownload(finishedItems));
}
}
19
Source : DynamicCharacterSystem.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public override List<string> GetRecipeNamesForRaceSlot(string race, string slot)
{
Refresh();
List<string> recipeNamesForRaceSlot = new List<string>();
if (Recipes.ContainsKey(race))
{
if (Recipes[race].ContainsKey(slot))
{
foreach (UMATextRecipe utr in Recipes[race][slot])
{
recipeNamesForRaceSlot.Add(utr.name);
}
}
}
return recipeNamesForRaceSlot;
}
19
Source : UMAWardrobeCollection.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public List<string> GetRacesRecipeNames(string race, DynamicCharacterSystem dcs)
{
var recipesToGet = GetRacesWardrobeSet(race);
List<string> recipesWeGot = new List<string>();
for (int i = 0; i < recipesToGet.Count; i++)
{
recipesWeGot.Add(recipesToGet[i].recipe);
}
return recipesWeGot;
}
19
Source : AssetBundleLoadingIndicator.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void Show(string bundleToCheck, string loadingMessage = "", string unpackingMessage = "", string loadedMessage = "")
{
var bundlesToCheckList = new List<string>();
bundlesToCheckList.Add(bundleToCheck);
Show(bundlesToCheckList, loadingMessage, unpackingMessage, loadedMessage);
}
19
Source : AssetBundleIndex.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public string[] GetAllreplacedetBundleNames()
{
List<string> replacedetBundleNames = new List<string>();
foreach (replacedetBundleIndexList ireplacedetList in bundlesIndex)
{
replacedetBundleNames.Add(ireplacedetList.replacedetBundleName);
}
return replacedetBundleNames.ToArray();
}
19
Source : AssetBundleIndex.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public string[] FindContainingreplacedetBundle(string replacedetNameOrFilename, string type = "")
{
List<string> replacedetFoundIn = new List<string>();
for (int i = 0; i < bundlesIndex.Count; i++)
{
for (int ii = 0; ii < bundlesIndex[i].replacedetBundlereplacedets.Count; ii++)
{
if (replacedetNameOrFilename == bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetName)
{
if (type == "" || (type != "" && (type == bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType || type == GetTypeWithoutreplacedembly(bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType))))
{
replacedetFoundIn.Add(bundlesIndex[i].replacedetBundleName);
}
}
}
}
//if we didn't find it check the filename?
if (replacedetFoundIn.Count == 0)
{
for (int i = 0; i < bundlesIndex.Count; i++)
{
for (int ii = 0; ii < bundlesIndex[i].replacedetBundlereplacedets.Count; ii++)
{
if (replacedetNameOrFilename == bundlesIndex[i].replacedetBundlereplacedets[ii].filename)
{
if (type == "" || (type != "" && (type == bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType || type == GetTypeWithoutreplacedembly(bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType))))
{
replacedetFoundIn.Add(bundlesIndex[i].replacedetBundleName);
}
}
}
}
}
return replacedetFoundIn.ToArray();
}
19
Source : AssetBundleIndex.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public string[] FindContainingreplacedetBundle(int? replacedetNameHash, string type = "")
{
List<string> replacedetFoundIn = new List<string>();
for (int i = 0; i < bundlesIndex.Count; i++)
{
for (int ii = 0; ii < bundlesIndex[i].replacedetBundlereplacedets.Count; ii++)
{
if (replacedetNameHash == bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetHash)
{
if (type == "" || (type != "" && (type == bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType || type == GetTypeWithoutreplacedembly(bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType))))
{
replacedetFoundIn.Add(bundlesIndex[i].replacedetBundleName);
}
}
}
}
return replacedetFoundIn.ToArray();
}
19
Source : AssetBundleIndex.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public string[] GetAllreplacedetsOfTypeInBundle(string replacedetBundleName, string type)
{
List<string> foundreplacedets = new List<string>();
foreach (replacedetBundleIndexList ireplacedetList in bundlesIndex)
{
if (ireplacedetList.replacedetBundleName == replacedetBundleName)
{
foreach (replacedetBundleIndexItem ireplacedet in ireplacedetList.replacedetBundlereplacedets)
{
if (type == "" || (type != "" && (type == ireplacedet.replacedetType || type == GetTypeWithoutreplacedembly(ireplacedet.replacedetType))))
{
foundreplacedets.Add(ireplacedet.replacedetName);
}
}
}
}
return foundreplacedets.ToArray();
}
19
Source : DynamicDNAConverterBehaviourEditor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private void Init()
{
if (_skelModPropDrawer == null)
_skelModPropDrawer = new SkeletonModifierPropertyDrawer();
hashNames.Clear();
hashes.Clear();
SerializedProperty hashList = serializedObject.FindProperty("hashList");
for (int i = 0; i < hashList.arraySize; i++)
{
hashNames.Add(hashList.GetArrayElementAtIndex(i).FindPropertyRelative("hashName").stringValue);
hashes.Add(hashList.GetArrayElementAtIndex(i).FindPropertyRelative("hash").intValue);
}
if (minimalMode == false)
{
bonesInSkeleton = new List<string>(hashNames.ToArray());
}
else
{
bonesInSkeleton = new List<string>(umaData.skeleton.BoneNames);
}
bonesInSkeleton.Sort();
UpdateDnaNames();
initialized = true;
}
19
Source : DynamicDNAConverterBehaviourEditor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
void UpdateHashNames()
{
hashNames.Clear();
hashes.Clear();
SerializedProperty hashList = serializedObject.FindProperty("hashList");
for (int i = 0; i < hashList.arraySize; i++)
{
hashNames.Add(hashList.GetArrayElementAtIndex(i).FindPropertyRelative("hashName").stringValue);
hashes.Add(hashList.GetArrayElementAtIndex(i).FindPropertyRelative("hash").intValue);
}
_skelModPropDrawer.UpdateHashNames(hashNames, hashes);
}
19
Source : UMAAssetIndexer.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
void ISerializationCallbackReceiver.OnAfterDeserialize()
{
var st = StartTimer();
#region typestuff
List<System.Type> newTypes = new List<System.Type>()
{
(typeof(SlotDatareplacedet)),
(typeof(OverlayDatareplacedet)),
(typeof(RaceData)),
(typeof(UMATextRecipe)),
(typeof(UMAWardrobeRecipe)),
(typeof(UMAWardrobeCollection)),
(typeof(RuntimeAnimatorController)),
#if UNITY_EDITOR
(typeof(AnimatorController)),
#endif
(typeof(DynamireplacedADnareplacedet)),
(typeof(Textreplacedet))
};
TypeToLookup = new Dictionary<System.Type, System.Type>()
{
{ (typeof(SlotDatareplacedet)),(typeof(SlotDatareplacedet)) },
{ (typeof(OverlayDatareplacedet)),(typeof(OverlayDatareplacedet)) },
{ (typeof(RaceData)),(typeof(RaceData)) },
{ (typeof(UMATextRecipe)),(typeof(UMATextRecipe)) },
{ (typeof(UMAWardrobeRecipe)),(typeof(UMAWardrobeRecipe)) },
{ (typeof(UMAWardrobeCollection)),(typeof(UMAWardrobeCollection)) },
{ (typeof(RuntimeAnimatorController)),(typeof(RuntimeAnimatorController)) },
#if UNITY_EDITOR
{ (typeof(AnimatorController)),(typeof(RuntimeAnimatorController)) },
#endif
{ typeof(Textreplacedet), typeof(Textreplacedet) },
{ (typeof(DynamireplacedADnareplacedet)), (typeof(DynamireplacedADnareplacedet)) }
};
List<string> invalidTypeNames = new List<string>();
// Add the additional Types.
foreach (string s in IndexedTypeNames)
{
if (s == "")
continue;
System.Type sType = System.Type.GetType(s);
if (sType == null)
{
invalidTypeNames.Add(s);
Debug.LogWarning("Could not find type for " + s);
continue;
}
newTypes.Add(sType);
if (!TypeToLookup.ContainsKey(sType))
{
TypeToLookup.Add(sType, sType);
}
}
Types = newTypes.ToArray();
if (invalidTypeNames.Count > 0)
{
foreach (string ivs in invalidTypeNames)
{
IndexedTypeNames.Remove(ivs);
}
}
BuildStringTypes();
#endregion
UpdateSerializedDictionaryItems();
StopTimer(st, "Before Serialize");
}
19
Source : AssetBundleManager.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
static protected bool LoadreplacedetBundleInternal(string replacedetBundleToFind, bool isLoadingreplacedetBundleIndex = false, bool useJsonIndex = false, string jsonIndexUrl = "")
{
//encrypted bundles have the suffix 'encrypted' appended to the name TODO this should probably go in the index though and be settable in the UMAreplacedetBundleManagerSettings window
//string encryptedSuffix = BundleEncryptionKey != "" ? "encrypted" : "";
string replacedetBundleToGet = replacedetBundleToFind;
if(BundleEncryptionKey != "" && m_replacedetBundleIndex != null)
{
replacedetBundleToGet = m_replacedetBundleIndex.GetreplacedetBundleEncryptedName(replacedetBundleToFind);
Debug.Log("replacedetBundleToFind was " + replacedetBundleToFind + " replacedetBundleToGet was " + replacedetBundleToGet);
}
else if(BundleEncryptionKey != "" && m_replacedetBundleIndex == null)
{
replacedetBundleToGet = replacedetBundleToFind + "encrypted";
}
// Already loaded.
LoadedreplacedetBundle bundle = null;
m_LoadedreplacedetBundles.TryGetValue(replacedetBundleToFind, out bundle);//encrypted or not this will have the replacedetbundlename without the 'encrypted' suffix
if (bundle != null && bundle.m_replacedetBundle != null)
{
bundle.m_ReferencedCount++;
return true;
}
// @TODO: Do we need to consider the referenced count of WWWs?
// users can call LoadreplacedetAsync()/LoadLevelAsync() several times then wait them to be finished which might have duplicate WWWs.
if (m_DownloadingBundles.Contains(replacedetBundleToFind))
return true;
string bundleBaseDownloadingURL = GetreplacedetBundleBaseDownloadingURL(replacedetBundleToFind);
//TODO These dont support encrypted bundles yet
if (bundleBaseDownloadingURL.ToLower().StartsWith("odr://"))
{
#if ENABLE_IOS_ON_DEMAND_RESOURCES
Log(LogType.Info, "Requesting bundle " + replacedetBundleToGet + " through ODR");
m_InProgressOperations.Add(new replacedetBundleDownloadFromODROperation(replacedetBundleToGet));
#else
new ApplicationException("Can't load bundle " + replacedetBundleToFind + " through ODR: this Unity version or build target doesn't support it.");
#endif
}
else if (bundleBaseDownloadingURL.ToLower().StartsWith("res://"))
{
#if ENABLE_IOS_APP_SLICING
Log(LogType.Info, "Requesting bundle " + replacedetBundleToGet + " through replacedet catalog");
m_InProgressOperations.Add(new replacedetBundleOpenFromreplacedetCatalogOperation(replacedetBundleToGet));
#else
new ApplicationException("Can't load bundle " + replacedetBundleToFind + " through replacedet catalog: this Unity version or build target doesn't support it.");
#endif
}
else
{
if (!bundleBaseDownloadingURL.EndsWith("/"))
bundleBaseDownloadingURL += "/";
string url = bundleBaseDownloadingURL + replacedetBundleToGet;
WWW download = null;
// For index replacedetbundle, always download it as we don't have hash for it.
//TODO make something to test if there is and internet connection and if not try to get a cached version of this so we can still access the stuff that has been previously cached
//TODO2 Make the index cache somewhere when it is downloaded.
if (isLoadingreplacedetBundleIndex)
{
if (useJsonIndex && jsonIndexUrl != "")
{
url = jsonIndexUrl.Replace("[PLATFORM]", Utility.GetPlatformName());
}
else if (useJsonIndex)
{
url = url+ ".json";
}
download = new WWW(url);
if (!String.IsNullOrEmpty(download.error) || download == null)
{
if (!String.IsNullOrEmpty(download.error))
Log(LogType.Warning, download.error);
else
Log(LogType.Warning, " index new WWW(url) was NULL");
}
}
else
{
download = WWW.LoadFromCacheOrDownload(url, m_replacedetBundleIndex.GetreplacedetBundleHash(replacedetBundleToFind), 0);
}
m_InProgressOperations.Add(new replacedetBundleDownloadFromWebOperation(replacedetBundleToFind/* + encryptedSuffix*/, download, useJsonIndex));
}
m_DownloadingBundles.Add(replacedetBundleToFind);
return false;
}
19
Source : AssetBundleManager.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
static public void UnloadAllreplacedetBundles()
{
#if UNITY_EDITOR
// If we're in Editor simulation mode, we don't have to load the manifest replacedetBundle.
if (SimulatereplacedetBundleInEditor)
return;
#endif
List<string> bundlesToUnload = new List<string>();
foreach (KeyValuePair<string, LoadedreplacedetBundle> kp in m_LoadedreplacedetBundles)
{
if (kp.Key.IndexOf(Utility.GetPlatformName().ToLower() + "index") == -1)//dont try to unload the index...
bundlesToUnload.Add(kp.Key);
}
foreach (string bundleName in bundlesToUnload)
{
UnloadreplacedetBundleInternal(bundleName);
UnloadDependencies(bundleName);//I think its unloading dependencies thats causing an issue with UMA
}
}
19
Source : DCSStandardTypes.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public List<string> GetAllRecipeNamesInCollection(string forRace = "")
{
var collectionNames = new List<string>();
for (int i = 0; i < sets.Count; i++)
{
if (forRace != "" && sets[i].targetRace != forRace)
continue;
for (int si = 0; si < sets[i].wardrobeSet.Count; si++)
{
if (sets[i].wardrobeSet[si].recipe != "")
{
collectionNames.Add(sets[i].wardrobeSet[si].recipe);
}
}
}
return collectionNames;
}
19
Source : pRaceData.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public List<string> GetCrossCompatibleRaces()
{
UpdateOldRace();
List<string> ccRaces = new List<string>();
for (int i = 0; i < _crossCompatibilitySettings.settingsData.Count; i++)
ccRaces.Add(_crossCompatibilitySettings.settingsData[i].ccRace);
return ccRaces;
}
19
Source : pRaceData.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void SetCrossCompatibleRaces(List<string> ccRaces)
{
for (int i = 0; i < ccRaces.Count; i++)
_crossCompatibilitySettings.Add(ccRaces[i]);
//then remove any that were not in the list
List<string> racesToRemove = new List<string>();
for (int i = 0; i < _crossCompatibilitySettings.settingsData.Count; i++)
{
if (!ccRaces.Contains(_crossCompatibilitySettings.settingsData[i].ccRace))
racesToRemove.Add(_crossCompatibilitySettings.settingsData[i].ccRace);
}
_crossCompatibilitySettings.Remove(racesToRemove);
}
19
Source : SerialBusManager.cs
with GNU General Public License v3.0
from a4004
with GNU General Public License v3.0
from a4004
private static string[] GetDeviceNames(string[] comPorts)
{
List<string> names = new List<string>();
foreach (string port in comPorts)
names.Add(GetDeviceName(port));
return names.ToArray();
}
19
Source : CameraBodyEditorWindow.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private void DrawLensField () {
List<string> hfovList = new List<string>();
List<string> offsetList = new List<string>();
ProCamsLensDataTable.FilmFormatData curFilmFormat = ProCamsLensDataTable.Instance.GetFilmFormat(_ffList[_currentFilmFormatIndex]);
if(curFilmFormat != null)
{
ProCamsLensDataTable.LensKitData lensKit = curFilmFormat.GetLensKitData(_lensKitIndex);
if(lensKit != null)
{
if(_lensList == null)
{
_lensList = new string[lensKit._fovDataset.Count];
int i = 0;
foreach(ProCamsLensDataTable.FOVData fovData in lensKit._fovDataset)
{
_lensList[i] = fovData._focalLength + "mm";
++i;
}
}
foreach(ProCamsLensDataTable.FOVData fovData in lensKit._fovDataset)
{
//float hfov = Lens.GetHorizontalFOV(curFilmFormat._aspect, fovData._unityVFOV);
// Rounding to two decimal places
//hfov = Mathf.Floor(hfov * 100) / 100f;
//hfovList.Add ("" + hfov);
float hfov = Mathf.Floor(fovData._realHFOV * 100) / 100f;
hfovList.Add (hfov.ToString());
offsetList.Add ("" + fovData._nodalOffset);
}
}
}
_lensIndex = EditorGUILayout.Popup("Lenses", _lensIndex, _lensList);
//GUILayout.Space(20f);
DrawNodalPointOffsetField(offsetList[_lensIndex]);
DrawHFOVField(hfovList[_lensIndex]);
}
19
Source : CameraBodyEditorWindow.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private void DrawLensField () {
List<string> hfovList = new List<string>();
List<string> offsetList = new List<string>();
ProCamsLensDataTable.FilmFormatData curFilmFormat = ProCamsLensDataTable.Instance.GetFilmFormat(_ffList[_currentFilmFormatIndex]);
if(curFilmFormat != null)
{
ProCamsLensDataTable.LensKitData lensKit = curFilmFormat.GetLensKitData(_lensKitIndex);
if(lensKit != null)
{
if(_lensList == null)
{
_lensList = new string[lensKit._fovDataset.Count];
int i = 0;
foreach(ProCamsLensDataTable.FOVData fovData in lensKit._fovDataset)
{
_lensList[i] = fovData._focalLength + "mm";
++i;
}
}
foreach(ProCamsLensDataTable.FOVData fovData in lensKit._fovDataset)
{
//float hfov = Lens.GetHorizontalFOV(curFilmFormat._aspect, fovData._unityVFOV);
// Rounding to two decimal places
//hfov = Mathf.Floor(hfov * 100) / 100f;
//hfovList.Add ("" + hfov);
float hfov = Mathf.Floor(fovData._realHFOV * 100) / 100f;
hfovList.Add (hfov.ToString());
offsetList.Add ("" + fovData._nodalOffset);
}
}
}
_lensIndex = EditorGUILayout.Popup("Lenses", _lensIndex, _lensList);
//GUILayout.Space(20f);
DrawNodalPointOffsetField(offsetList[_lensIndex]);
DrawHFOVField(hfovList[_lensIndex]);
}
19
Source : DynamicDnaConverterCustomizerEditor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public override void OnInspectorGUI()
{
thisDDCC = target as DynamicDNAConverterCustomizer;
serializedObject.Update();
EditorGUILayout.PropertyField(serializedObject.FindProperty("dynamicDnaConverterPrefab"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("TposeAnimatorController"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("AposeAnimatorController"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("MovementAnimatorController"));
if (Application.isPlaying)
{
EditorGUILayout.BeginHorizontal();
if (serializedObject.FindProperty("TposeAnimatorController").objectReferenceValue != null)
{
if (GUILayout.Button("Set T-Pose"))
{
thisDDCC.SetTPoseAni();
}
}
if (serializedObject.FindProperty("AposeAnimatorController").objectReferenceValue != null)
{
if (GUILayout.Button("Set A-Pose"))
{
thisDDCC.SetAPoseAni();
}
}
if (serializedObject.FindProperty("MovementAnimatorController").objectReferenceValue != null)
{
if (GUILayout.Button("Animate UMA"))
{
thisDDCC.SetMovementAni();
}
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.Space();
EditorGUILayout.PropertyField(serializedObject.FindProperty("targetUMA"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("guideUMA"));
if(serializedObject.FindProperty("guideUMA").objectReferenceValue != null && Application.isPlaying)
{
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Align Guide To Target"))
{
thisDDCC.AlignGuideToTarget();
}
if (GUILayout.Button("Import Guide DNA Values"))
{
thisDDCC.ImportGuideDNAValues();
}
EditorGUILayout.EndHorizontal();
}
if (Application.isPlaying)
{
SerializedProperty availableConvertersProp = serializedObject.FindProperty("availableConverters");
SerializedProperty selectedConverterProp = serializedObject.FindProperty("selectedConverter");
List<string> availableConvertersPopup = new List<string>();
availableConvertersPopup.Add("None Selected");
int selectedConverterIndex = 0;
int newSelectedConverterIndex = 0;
for (int i = 0; i < availableConvertersProp.arraySize; i++)
{
availableConvertersPopup.Add(availableConvertersProp.GetArrayElementAtIndex(i).objectReferenceValue.name);
if (selectedConverterProp.objectReferenceValue != null)
if (availableConvertersProp.GetArrayElementAtIndex(i).objectReferenceValue.name == selectedConverterProp.objectReferenceValue.name)
{
selectedConverterIndex = i + 1;
}
}
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
newSelectedConverterIndex = EditorGUILayout.Popup("Target UMA Converter", selectedConverterIndex, availableConvertersPopup.ToArray());
if (EditorGUI.EndChangeCheck())
{
if (newSelectedConverterIndex != selectedConverterIndex)
{
if (newSelectedConverterIndex == 0)
{
selectedConverterProp.objectReferenceValue = null;
}
else
{
selectedConverterProp.objectReferenceValue = availableConvertersProp.GetArrayElementAtIndex(newSelectedConverterIndex - 1).objectReferenceValue;
}
serializedObject.ApplyModifiedProperties();
thisDDCC.BackupConverter();
}
}
}
if (serializedObject.FindProperty("selectedConverter").objectReferenceValue != null)
{
thisDDCC.StartListeningForUndo();
GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
EditorGUILayout.LabelField("Import Settings from another Converter", EditorStyles.boldLabel);
var ImportFromConverterR = EditorGUILayout.GetControlRect(false);
var ImportFromConverterLabelR = ImportFromConverterR;
var ImportFromConverterFieldR = ImportFromConverterR;
var ImportFromConverterButR = ImportFromConverterR;
ImportFromConverterLabelR.width = 140;
ImportFromConverterButR.width = 70;
ImportFromConverterFieldR.width = ImportFromConverterFieldR.width - ImportFromConverterLabelR.width - ImportFromConverterButR.width;
ImportFromConverterFieldR.x = ImportFromConverterLabelR.xMax;
ImportFromConverterButR.x = ImportFromConverterFieldR.xMax + 5;
EditorGUI.LabelField(ImportFromConverterLabelR, "Import from Converter");
EditorGUI.ObjectField(ImportFromConverterFieldR, serializedObject.FindProperty("converterToImport"), GUIContent.none);
if (serializedObject.FindProperty("converterToImport").objectReferenceValue == null)
EditorGUI.BeginDisabledGroup(true);
if(GUI.Button(ImportFromConverterButR, "Import"))
{
if (thisDDCC.ImportConverterValues())
{
serializedObject.FindProperty("converterToImport").objectReferenceValue = null;
}
}
if (serializedObject.FindProperty("converterToImport").objectReferenceValue == null)
EditorGUI.EndDisabledGroup();
GUIHelper.EndVerticalPadded(10);
//
Editor thisSDCB;
if(SDCBs.TryGetValue((DynamicDNAConverterBehaviour)serializedObject.FindProperty("selectedConverter").objectReferenceValue, out thisSDCB))
{
((DynamicDNAConverterBehaviourEditor)thisSDCB).initialized = true;
}
else
{
thisSDCB = Editor.CreateEditor((DynamicDNAConverterBehaviour)serializedObject.FindProperty("selectedConverter").objectReferenceValue, typeof(DynamicDNAConverterBehaviourEditor));
SDCBs.Add((DynamicDNAConverterBehaviour)serializedObject.FindProperty("selectedConverter").objectReferenceValue, thisSDCB);
}
((DynamicDNAConverterBehaviourEditor)thisSDCB).minimalMode = true;
((DynamicDNAConverterBehaviourEditor)thisSDCB).thisDDCC = thisDDCC;
((DynamicDNAConverterBehaviourEditor)thisSDCB).umaData = thisDDCC.targetUMA.umaData;
GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
EditorGUILayout.LabelField("Edit Values", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
thisSDCB.OnInspectorGUI();
if (EditorGUI.EndChangeCheck())
{
thisDDCC.UpdateUMA();
}
GUIHelper.EndVerticalPadded(10);
GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
EditorGUILayout.LabelField("Save Values", EditorStyles.boldLabel);
Rect thisR = EditorGUILayout.GetControlRect(false);
var thisButReset = thisR;
var thisButSave = thisR;
var thisButSaveNew = thisR;
thisButReset.width = thisButSave.width = thisButSaveNew.width = (thisR.width / 3) - 2;
thisButSave.x = thisButReset.xMax + 5;
thisButSaveNew.x = thisButSave.xMax + 5;
if (GUI.Button(thisButReset, new GUIContent("Reset", "Undo your changes to the currently selected converter")))
{
thisDDCC.RestoreBackupVersion(serializedObject.FindProperty("selectedConverter").objectReferenceValue.name);
}
if (GUI.Button(thisButSave, new GUIContent("Save", "Save your changes to the currently selected converter")))
{
thisDDCC.SaveChanges();
}
if (GUI.Button(thisButSaveNew, new GUIContent("Save as New", "Save your changes to a new converter instance")))
{
thisDDCC.SaveChangesAsNew();
}
GUIHelper.EndVerticalPadded(10);
}
else
{
thisDDCC.StopListeningForUndo();
}
serializedObject.ApplyModifiedProperties();
}
19
Source : DynamicDnaConverterCustomizerEditor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public override void OnInspectorGUI()
{
thisDDCC = target as DynamicDNAConverterCustomizer;
serializedObject.Update();
EditorGUILayout.PropertyField(serializedObject.FindProperty("dynamicDnaConverterPrefab"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("TposeAnimatorController"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("AposeAnimatorController"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("MovementAnimatorController"));
if (Application.isPlaying)
{
EditorGUILayout.BeginHorizontal();
if (serializedObject.FindProperty("TposeAnimatorController").objectReferenceValue != null)
{
if (GUILayout.Button("Set T-Pose"))
{
thisDDCC.SetTPoseAni();
}
}
if (serializedObject.FindProperty("AposeAnimatorController").objectReferenceValue != null)
{
if (GUILayout.Button("Set A-Pose"))
{
thisDDCC.SetAPoseAni();
}
}
if (serializedObject.FindProperty("MovementAnimatorController").objectReferenceValue != null)
{
if (GUILayout.Button("Animate UMA"))
{
thisDDCC.SetMovementAni();
}
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.Space();
EditorGUILayout.PropertyField(serializedObject.FindProperty("targetUMA"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("guideUMA"));
if(serializedObject.FindProperty("guideUMA").objectReferenceValue != null && Application.isPlaying)
{
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Align Guide To Target"))
{
thisDDCC.AlignGuideToTarget();
}
if (GUILayout.Button("Import Guide DNA Values"))
{
thisDDCC.ImportGuideDNAValues();
}
EditorGUILayout.EndHorizontal();
}
if (Application.isPlaying)
{
SerializedProperty availableConvertersProp = serializedObject.FindProperty("availableConverters");
SerializedProperty selectedConverterProp = serializedObject.FindProperty("selectedConverter");
List<string> availableConvertersPopup = new List<string>();
availableConvertersPopup.Add("None Selected");
int selectedConverterIndex = 0;
int newSelectedConverterIndex = 0;
for (int i = 0; i < availableConvertersProp.arraySize; i++)
{
availableConvertersPopup.Add(availableConvertersProp.GetArrayElementAtIndex(i).objectReferenceValue.name);
if (selectedConverterProp.objectReferenceValue != null)
if (availableConvertersProp.GetArrayElementAtIndex(i).objectReferenceValue.name == selectedConverterProp.objectReferenceValue.name)
{
selectedConverterIndex = i + 1;
}
}
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
newSelectedConverterIndex = EditorGUILayout.Popup("Target UMA Converter", selectedConverterIndex, availableConvertersPopup.ToArray());
if (EditorGUI.EndChangeCheck())
{
if (newSelectedConverterIndex != selectedConverterIndex)
{
if (newSelectedConverterIndex == 0)
{
selectedConverterProp.objectReferenceValue = null;
}
else
{
selectedConverterProp.objectReferenceValue = availableConvertersProp.GetArrayElementAtIndex(newSelectedConverterIndex - 1).objectReferenceValue;
}
serializedObject.ApplyModifiedProperties();
thisDDCC.BackupConverter();
}
}
}
if (serializedObject.FindProperty("selectedConverter").objectReferenceValue != null)
{
thisDDCC.StartListeningForUndo();
GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
EditorGUILayout.LabelField("Import Settings from another Converter", EditorStyles.boldLabel);
var ImportFromConverterR = EditorGUILayout.GetControlRect(false);
var ImportFromConverterLabelR = ImportFromConverterR;
var ImportFromConverterFieldR = ImportFromConverterR;
var ImportFromConverterButR = ImportFromConverterR;
ImportFromConverterLabelR.width = 140;
ImportFromConverterButR.width = 70;
ImportFromConverterFieldR.width = ImportFromConverterFieldR.width - ImportFromConverterLabelR.width - ImportFromConverterButR.width;
ImportFromConverterFieldR.x = ImportFromConverterLabelR.xMax;
ImportFromConverterButR.x = ImportFromConverterFieldR.xMax + 5;
EditorGUI.LabelField(ImportFromConverterLabelR, "Import from Converter");
EditorGUI.ObjectField(ImportFromConverterFieldR, serializedObject.FindProperty("converterToImport"), GUIContent.none);
if (serializedObject.FindProperty("converterToImport").objectReferenceValue == null)
EditorGUI.BeginDisabledGroup(true);
if(GUI.Button(ImportFromConverterButR, "Import"))
{
if (thisDDCC.ImportConverterValues())
{
serializedObject.FindProperty("converterToImport").objectReferenceValue = null;
}
}
if (serializedObject.FindProperty("converterToImport").objectReferenceValue == null)
EditorGUI.EndDisabledGroup();
GUIHelper.EndVerticalPadded(10);
//
Editor thisSDCB;
if(SDCBs.TryGetValue((DynamicDNAConverterBehaviour)serializedObject.FindProperty("selectedConverter").objectReferenceValue, out thisSDCB))
{
((DynamicDNAConverterBehaviourEditor)thisSDCB).initialized = true;
}
else
{
thisSDCB = Editor.CreateEditor((DynamicDNAConverterBehaviour)serializedObject.FindProperty("selectedConverter").objectReferenceValue, typeof(DynamicDNAConverterBehaviourEditor));
SDCBs.Add((DynamicDNAConverterBehaviour)serializedObject.FindProperty("selectedConverter").objectReferenceValue, thisSDCB);
}
((DynamicDNAConverterBehaviourEditor)thisSDCB).minimalMode = true;
((DynamicDNAConverterBehaviourEditor)thisSDCB).thisDDCC = thisDDCC;
((DynamicDNAConverterBehaviourEditor)thisSDCB).umaData = thisDDCC.targetUMA.umaData;
GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
EditorGUILayout.LabelField("Edit Values", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
thisSDCB.OnInspectorGUI();
if (EditorGUI.EndChangeCheck())
{
thisDDCC.UpdateUMA();
}
GUIHelper.EndVerticalPadded(10);
GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
EditorGUILayout.LabelField("Save Values", EditorStyles.boldLabel);
Rect thisR = EditorGUILayout.GetControlRect(false);
var thisButReset = thisR;
var thisButSave = thisR;
var thisButSaveNew = thisR;
thisButReset.width = thisButSave.width = thisButSaveNew.width = (thisR.width / 3) - 2;
thisButSave.x = thisButReset.xMax + 5;
thisButSaveNew.x = thisButSave.xMax + 5;
if (GUI.Button(thisButReset, new GUIContent("Reset", "Undo your changes to the currently selected converter")))
{
thisDDCC.RestoreBackupVersion(serializedObject.FindProperty("selectedConverter").objectReferenceValue.name);
}
if (GUI.Button(thisButSave, new GUIContent("Save", "Save your changes to the currently selected converter")))
{
thisDDCC.SaveChanges();
}
if (GUI.Button(thisButSaveNew, new GUIContent("Save as New", "Save your changes to a new converter instance")))
{
thisDDCC.SaveChangesAsNew();
}
GUIHelper.EndVerticalPadded(10);
}
else
{
thisDDCC.StopListeningForUndo();
}
serializedObject.ApplyModifiedProperties();
}
19
Source : UMAAssetIndexer.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void AddType(System.Type sType)
{
string QualifiedName = sType.replacedemblyQualifiedName;
if (IsAdditionalIndexedType(QualifiedName)) return;
List<System.Type> newTypes = new List<System.Type>();
newTypes.AddRange(Types);
newTypes.Add(sType);
Types = newTypes.ToArray();
TypeToLookup.Add(sType, sType);
IndexedTypeNames.Add(sType.replacedemblyQualifiedName);
BuildStringTypes();
}
19
Source : WebServer.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
void OnGetContext(IAsyncResult async)
{
// start listening for the next request
_listener.BeginGetContext(OnGetContext, null);
var context = _listener.EndGetContext(async);
try
{
if (context.Request.RawUrl == "/")
{
Debug.Log("[WebServer] context.Request.RawUrl");
context.Response.StatusCode = 200;
var process = System.Diagnostics.Process.GetCurrentProcess();
string msg = string.Format(@"<html><body><h1>UMA Simple Web Server</h1><table>
<tr><td>Host Application</td><td>{0} (Process Id: {1})</td></tr>
<tr><td>Working Directory</td><td>{2}</td></tr>
</table><br><br>{3}</body></html>", process.ProcessName, process.Id, System.IO.Directory.GetCurrentDirectory(), GetLog("<br>"));
var data = System.Text.Encoding.UTF8.GetBytes(msg);
context.Response.OutputStream.Write(data, 0, data.Length);
context.Response.OutputStream.Close();
//Tried adding response close aswell like in Adamas original
context.Response.Close();
}
else
{
var filePath = System.IO.Path.Combine(_hostedFolder, context.Request.RawUrl.Substring(1));
if (System.IO.File.Exists(filePath))
{
using (var file = System.IO.File.Open(filePath, System.IO.FileMode.Open))
{
var buffer = new byte[file.Length];
file.Read(buffer, 0, (int)file.Length);
context.Response.ContentLength64 = file.Length;
context.Response.StatusCode = 200;
context.Response.OutputStream.Write(buffer, 0, (int)file.Length);
}
}
else
{
context.Response.StatusCode = 404;
UnityEngine.Debug.LogErrorFormat("Url not served. Have you built your replacedet Bundles? Url not served from: {0} '{1}'", context.Request.RawUrl, filePath);
#if UNITY_EDITOR
replacedetBundleManager.SimulateOverride = true;
context.Response.OutputStream.Close();
//Tried adding response close aswell like in Adamas original
context.Response.Abort();
return;
#endif
}
}
lock (_requestLog)
{
_requestLog.Add(string.Format("{0} {1}", context.Response.StatusCode, context.Request.Url));
}
context.Response.OutputStream.Close();
context.Response.Close();
}
catch (HttpListenerException e)
{
if (e.ErrorCode == -2147467259)
{
// shutdown, terminate silently
Debug.LogWarning("[Web Server] ErrorCode -2147467259: terminate silently");
context.Response.Abort();
return;
}
UnityEngine.Debug.LogException(e);
context.Response.Abort();
}
catch (Exception e)
{
UnityEngine.Debug.LogException(e);
context.Response.Abort();
}
}
19
Source : DCSStandardTypes.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public List<string> GetAllRacesInCollection()
{
List<string> ret = new List<string>();
for (int i = 0; i < sets.Count; i++)
{
ret.Add(sets[i].targetRace);
}
return ret;
}
19
Source : UMAMaterialInspector.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private static string[] FindTexProperties( Shader shader)
{
int count = ShaderUtil.GetPropertyCount(shader);
if (count <= 0)
return null;
List<string> texProperties = new List<string>();
texProperties.Add("Select");
for (int i = 0; i < count; i++)
{
if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv)
texProperties.Add(ShaderUtil.GetPropertyName(shader, i));
}
return texProperties.ToArray();
}
19
Source : UMAMaterialInspector.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private static string[] FindTexProperties( Shader shader)
{
int count = ShaderUtil.GetPropertyCount(shader);
if (count <= 0)
return null;
List<string> texProperties = new List<string>();
texProperties.Add("Select");
for (int i = 0; i < count; i++)
{
if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv)
texProperties.Add(ShaderUtil.GetPropertyName(shader, i));
}
return texProperties.ToArray();
}
19
Source : FormulaHelper.cs
with Apache License 2.0
from aaaddress1
with Apache License 2.0
from aaaddress1
public static List<string> BuildPayloadMacros(byte[] payload)
{
int maxCellSize = 255;
List<string> macros = new List<string>();
string curMacroString = "";
foreach (byte b in payload)
{
if (b == (byte) 0)
{
throw new ArgumentException("Payloads with null bytes must use the Base64 Payload Method.");
}
curMacroString += (char) b;
if (curMacroString.Length == maxCellSize)
{
macros.Add(curMacroString);
curMacroString = "";
}
}
macros.Add(curMacroString);
macros.Add("END");
return macros;
}
19
Source : StringExtensions.cs
with Apache License 2.0
from aaaddress1
with Apache License 2.0
from aaaddress1
public static List<String> SplitStringIntoChunks(this string str, int maxChunkSize)
{
List<string> chunks = new List<string>();
for (int offset = 0; offset < str.Length; offset += maxChunkSize)
{
int bytesRemaining = str.Length - offset;
int chunkSize = maxChunkSize;
if (chunkSize > bytesRemaining)
{
chunkSize = bytesRemaining;
}
chunks.Add(new string(str.Skip(offset).Take(chunkSize).ToArray()));
}
return chunks;
}
19
Source : Program.cs
with Apache License 2.0
from aaaddress1
with Apache License 2.0
from aaaddress1
static WorkbookEditor cmd_ModifyLabel(WorkbookEditor wbe)
{
List<Lbl> existingLbls = wbe.WbStream.GetAllRecordsByType<Lbl>();
log("\t[+] Detect {0} Labels ...\n", ConsoleColor.Yellow, existingLbls.Count);
for (int i = 0; i < existingLbls.Count; i++)
{ // XLUnicodeStringNoCch
var labelName = existingLbls[i].IsAutoOpenLabel() ? "Auto_Open" : existingLbls[i].Name.Value;
log("\t\t[{0}] {1:s}\n", ConsoleColor.Yellow, i, labelName);
}
log("\t[?] which one to midify (index): ", ConsoleColor.Yellow);
try
{
int indx = Convert.ToInt32(Console.ReadLine());
var labelName = existingLbls[indx].IsAutoOpenLabel() ? "Auto_Open" : existingLbls[indx].Name.Value;
log("\t[v] select label `{0}`\n", ConsoleColor.Yellow, labelName);
log("\t\t[1] hide label\n", ConsoleColor.Yellow);
log("\t\t[2] obfuscate label\n", ConsoleColor.Yellow);
log("\t[?] choose action (index): ", ConsoleColor.Yellow);
var replaceLabelStringLbl = ((BiffRecord)existingLbls[indx].Clone()).AsRecordType<Lbl>();
switch (Convert.ToInt32(Console.ReadLine())) {
case 1:
replaceLabelStringLbl.fHidden = true;
wbe.WbStream = wbe.WbStream.ReplaceRecord(existingLbls[indx], replaceLabelStringLbl);
wbe.WbStream = wbe.WbStream. FixBoundSheetOffsets();
historyList.Add(string.Format("[#] History - label `{0}` vanish!\n", labelName));
break;
case 2:
replaceLabelStringLbl.SetName(new XLUnicodeStringNoCch(getObfscuteName(labelName), true));
replaceLabelStringLbl.fBuiltin = false;
wbe.WbStream = wbe.WbStream.ReplaceRecord(existingLbls[indx], replaceLabelStringLbl);
wbe.WbStream = wbe.WbStream.FixBoundSheetOffsets();
historyList.Add(string.Format("[#] History - obfuscate `{0}` done!\n", labelName));
break;
}
}
catch (Exception) {}
return wbe;
}
19
Source : Database.cs
with Apache License 2.0
from aadreja
with Apache License 2.0
from aadreja
internal virtual void CreateAddCommand(IDbCommand cmd, object enreplacedy, IAuditTrail audit = null, string columnNames = null, bool doNotAppendCommonFields = false, bool overrideCreatedUpdatedOn = false)
{
TableAttribute tableInfo = EnreplacedyCache.Get(enreplacedy.GetType());
if (tableInfo.NeedsHistory && tableInfo.IsCreatedByEmpty(enreplacedy))
throw new MissingFieldException("CreatedBy is required when Audit Trail is enabled");
List<string> columns = new List<string>();
if (!string.IsNullOrEmpty(columnNames)) columns.AddRange(columnNames.Split(','));
else columns.AddRange(tableInfo.DefaultInsertColumns);//Get columns from Enreplacedy attributes loaded in TableInfo
bool isPrimaryKeyEmpty = false;
foreach(ColumnAttribute pkCol in tableInfo.Columns.Where(p=>p.Value.IsPrimaryKey).Select(p=>p.Value))
{
if (pkCol.PrimaryKeyInfo.IsIdenreplacedy && tableInfo.IsKeyIdEmpty(enreplacedy, pkCol))
{
isPrimaryKeyEmpty = true;
//if idenreplacedy remove keyfield if added in field list
columns.Remove(pkCol.Name);
}
else if (pkCol.Property.PropertyType == typeof(Guid) && tableInfo.IsKeyIdEmpty(enreplacedy, pkCol))
{
isPrimaryKeyEmpty = true;
//if not idenreplacedy and key not generated, generate before save
tableInfo.SetKeyId(enreplacedy, pkCol, Guid.NewGuid());
}
}
#region append common columns
if (!doNotAppendCommonFields)
{
if (!tableInfo.NoIsActive)
{
if (!columns.Contains(Config.ISACTIVE_COLUMN.Name))
columns.Add(Config.ISACTIVE_COLUMN.Name);
bool isActive = tableInfo.GetIsActive(enreplacedy) ?? true;
//when IsActive is not set then true for insert
cmd.AddInParameter("@" + Config.ISACTIVE_COLUMN.Name, Config.ISACTIVE_COLUMN.ColumnDbType, isActive);
if (tableInfo.NeedsHistory)
audit.AppendDetail(Config.ISACTIVE_COLUMN.Name, isActive, DbType.Boolean, null);
tableInfo.SetIsActive(enreplacedy, isActive); //Set IsActive value
}
if (!tableInfo.NoVersionNo)
{
int versionNo = tableInfo.GetVersionNo(enreplacedy) ?? 1; //set defualt versionno 1 for Insert
if (versionNo == 0) versionNo = 1; //set defualt versionno 1 for Insert even if its zero or null
if (!columns.Contains(Config.VERSIONNO_COLUMN.Name))
columns.Add(Config.VERSIONNO_COLUMN.Name);
cmd.AddInParameter("@" + Config.VERSIONNO_COLUMN.Name, Config.VERSIONNO_COLUMN.ColumnDbType, versionNo);
tableInfo.SetVersionNo(enreplacedy, versionNo); //Set VersionNo value
}
if (!tableInfo.NoCreatedBy)
{
if (!columns.Contains(Config.CREATEDBY_COLUMN.Name))
columns.Add(Config.CREATEDBY_COLUMN.Name);
cmd.AddInParameter("@" + Config.CREATEDBY_COLUMN.Name, Config.CREATEDBY_COLUMN.ColumnDbType, tableInfo.GetCreatedBy(enreplacedy));
}
if (!tableInfo.NoCreatedOn & !columns.Contains(Config.CREATEDON_COLUMN.Name))
{
columns.Add(Config.CREATEDON_COLUMN.Name);
}
if (!tableInfo.NoUpdatedBy)
{
if (!columns.Contains(Config.UPDATEDBY_COLUMN.Name))
columns.Add(Config.UPDATEDBY_COLUMN.Name);
cmd.AddInParameter("@" + Config.UPDATEDBY_COLUMN.Name, Config.UPDATEDBY_COLUMN.ColumnDbType, tableInfo.GetCreatedBy(enreplacedy));
}
if (!tableInfo.NoUpdatedOn & !columns.Contains(Config.UPDATEDON_COLUMN.Name))
{
columns.Add(Config.UPDATEDON_COLUMN.Name);
}
}
#endregion
//append @ before each fields to add as parameter
List<string> parameters = columns.Select(c => "@" + c).ToList();
int pIndex = parameters.FindIndex(c => c == "@" + Config.CREATEDON_COLUMN.Name);
if (pIndex >= 0)
{
var createdOn = Helper.GetDateTimeOrDatabaseDateTimeSQL(tableInfo.GetCreatedOn(enreplacedy), this, overrideCreatedUpdatedOn);
if (createdOn is string)
{
parameters[pIndex] = (string)createdOn;
}
else
{
cmd.AddInParameter(parameters[pIndex], Config.CREATEDON_COLUMN.ColumnDbType, createdOn);
}
//parameters[pIndex] = (string)Helper.GetDateTimeOrDatabaseDateTimeSQL(tableInfo.GetCreatedOn(enreplacedy), this, overrideCreatedUpdatedOn);
}
pIndex = parameters.FindIndex(c => c == "@" + Config.UPDATEDON_COLUMN.Name);
if (pIndex >= 0)
{
var updatedOn = Helper.GetDateTimeOrDatabaseDateTimeSQL(tableInfo.GetUpdatedOn(enreplacedy), this, overrideCreatedUpdatedOn);
if (updatedOn is string)
{
parameters[pIndex] = (string)updatedOn;
}
else
{
cmd.AddInParameter(parameters[pIndex], Config.CREATEDON_COLUMN.ColumnDbType, updatedOn);
}
//parameters[pIndex] = (string)Helper.GetDateTimeOrDatabaseDateTimeSQL(tableInfo.GetUpdatedOn(enreplacedy), this, overrideCreatedUpdatedOn);
}
StringBuilder cmdText = new StringBuilder();
cmdText.Append($"INSERT INTO {tableInfo.FullName} ({string.Join(",", columns)}) VALUES({string.Join(",", parameters)});");
if (tableInfo.IsKeyIdenreplacedy() && isPrimaryKeyEmpty)
{
//add query to get inserted id
cmdText.Append(LASTINSERTEDROWIDSQL);
}
//remove common columns and parameters already added above
columns.RemoveAll(c => c == Config.CREATEDON_COLUMN.Name || c == Config.CREATEDBY_COLUMN.Name
|| c == Config.UPDATEDON_COLUMN.Name || c == Config.UPDATEDBY_COLUMN.Name
|| c == Config.VERSIONNO_COLUMN.Name || c == Config.ISACTIVE_COLUMN.Name);
cmd.CommandType = CommandType.Text;
cmd.CommandText = cmdText.ToString();
for (int i = 0; i < columns.Count(); i++)
{
tableInfo.Columns.TryGetValue(columns[i], out ColumnAttribute columnInfo); //find column attribute
DbType dbType = DbType.Object;
object columnValue = null;
if (columnInfo != null && columnInfo.GetMethod != null)
{
dbType = columnInfo.ColumnDbType;
columnValue = columnInfo.GetAction(enreplacedy);
if (tableInfo.NeedsHistory) audit.AppendDetail(columns[i], columnValue, dbType, null);
}
cmd.AddInParameter("@" + columns[i], dbType, columnValue);
}
}
19
Source : TestCustomizerDD.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void SetUpRacesDropdown(string selected = "")
{
string newSelected = selected;
if (newSelected == "")
{
if (Avatar != null)
{
newSelected = Avatar.activeRace.name;
}
}
changeRaceDropdown.options.Clear();
changeRaceDropdown.onValueChanged.RemoveListener(ChangeRace);
var raceDropdownOptionsArray = (Avatar.context.raceLibrary as DynamicRaceLibrary).GetAllRacesBase();
raceDropdownOptions = new List<string>();
//add the 'NoneSet'
raceDropdownOptions.Add("None Set");
foreach (RaceData r in raceDropdownOptionsArray)
{
if (r.raceName != "PlaceholderRace" && r.raceName != "RaceDataPlaceholder")
raceDropdownOptions.Add(r.raceName);
}
for (int i = 0; i < raceDropdownOptions.Count; i++)
{
var thisddOption = new Dropdown.OptionData();
thisddOption.text = raceDropdownOptions[i];
changeRaceDropdown.options.Add(thisddOption);
}
for (int i = 0; i < raceDropdownOptions.Count; i++)
{
if (raceDropdownOptions[i] == newSelected)
{
changeRaceDropdown.value = i;
}
}
// we also need to make the raceChangeOptions toggles match the settings in the component
Toggle[] thisChangeRaceToggles = null;
if(changeRaceDropdown.template.Find("ChangeRaceOptsHolder") != null)
if(changeRaceDropdown.template.Find("ChangeRaceOptsHolder").Find("ChangeRaceToggles") != null)
if(changeRaceDropdown.template.Find("ChangeRaceOptsHolder").Find("ChangeRaceToggles").GetComponentsInChildren<Toggle>().Length != 0)
thisChangeRaceToggles = changeRaceDropdown.template.Find("ChangeRaceOptsHolder").Find("ChangeRaceToggles").GetComponentsInChildren<Toggle>();
if(thisChangeRaceToggles != null)
for(int i = 0; i < thisChangeRaceToggles.Length; i++)
{
if (thisChangeRaceToggles[i].gameObject.name == "KeepDNA")
thisChangeRaceToggles[i].isOn = _keepDNA;
else if (thisChangeRaceToggles[i].gameObject.name == "KeepWardrobe")
thisChangeRaceToggles[i].isOn = _keepWardrobe;
else if (thisChangeRaceToggles[i].gameObject.name == "KeepBodyColors")
thisChangeRaceToggles[i].isOn = _keepBodyColors;
}
changeRaceDropdown.onValueChanged.AddListener(ChangeRace);
}
19
Source : TestCustomizerDD.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void SetUpRacesDropdown(string selected = "")
{
string newSelected = selected;
if (newSelected == "")
{
if (Avatar != null)
{
newSelected = Avatar.activeRace.name;
}
}
changeRaceDropdown.options.Clear();
changeRaceDropdown.onValueChanged.RemoveListener(ChangeRace);
var raceDropdownOptionsArray = (Avatar.context.raceLibrary as DynamicRaceLibrary).GetAllRacesBase();
raceDropdownOptions = new List<string>();
//add the 'NoneSet'
raceDropdownOptions.Add("None Set");
foreach (RaceData r in raceDropdownOptionsArray)
{
if (r.raceName != "PlaceholderRace" && r.raceName != "RaceDataPlaceholder")
raceDropdownOptions.Add(r.raceName);
}
for (int i = 0; i < raceDropdownOptions.Count; i++)
{
var thisddOption = new Dropdown.OptionData();
thisddOption.text = raceDropdownOptions[i];
changeRaceDropdown.options.Add(thisddOption);
}
for (int i = 0; i < raceDropdownOptions.Count; i++)
{
if (raceDropdownOptions[i] == newSelected)
{
changeRaceDropdown.value = i;
}
}
// we also need to make the raceChangeOptions toggles match the settings in the component
Toggle[] thisChangeRaceToggles = null;
if(changeRaceDropdown.template.Find("ChangeRaceOptsHolder") != null)
if(changeRaceDropdown.template.Find("ChangeRaceOptsHolder").Find("ChangeRaceToggles") != null)
if(changeRaceDropdown.template.Find("ChangeRaceOptsHolder").Find("ChangeRaceToggles").GetComponentsInChildren<Toggle>().Length != 0)
thisChangeRaceToggles = changeRaceDropdown.template.Find("ChangeRaceOptsHolder").Find("ChangeRaceToggles").GetComponentsInChildren<Toggle>();
if(thisChangeRaceToggles != null)
for(int i = 0; i < thisChangeRaceToggles.Length; i++)
{
if (thisChangeRaceToggles[i].gameObject.name == "KeepDNA")
thisChangeRaceToggles[i].isOn = _keepDNA;
else if (thisChangeRaceToggles[i].gameObject.name == "KeepWardrobe")
thisChangeRaceToggles[i].isOn = _keepWardrobe;
else if (thisChangeRaceToggles[i].gameObject.name == "KeepBodyColors")
thisChangeRaceToggles[i].isOn = _keepBodyColors;
}
changeRaceDropdown.onValueChanged.AddListener(ChangeRace);
}
19
Source : TestCustomizerDD.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void SetUpColorDropdowns()
{
UMA.UMAData umaData = Avatar.umaData;
thisRace = Avatar.activeRace.name;
var currentColorDropdowns = colorDropdownPanel.transform.GetComponentsInChildren<CSColorChangerDD>(true);
List<string> activeColorDropdowns = new List<string>();
//foreach (DynamicCharacterAvatar.ColorValue colorType in Avatar.characterColors.Colors)
//using new colorvaluestuff
foreach (OverlayColorData colorType in Avatar.characterColors.Colors)
{
activeColorDropdowns.Add(colorType.name);
bool dropdownExists = false;
foreach (CSColorChangerDD colorDropdown in currentColorDropdowns)
{
if (colorDropdown.colorToChange == colorType.name)
{
dropdownExists = true;
colorDropdown.gameObject.SetActive(true);
SetUpColorDropdownValue(colorDropdown, colorType);
break;
}
}
if (!dropdownExists)
{
GameObject thisColorDropdown = Instantiate(colorDropdownPrefab) as GameObject;
thisColorDropdown.transform.SetParent(colorDropdownPanel.transform, false);
thisColorDropdown.GetComponent<CSColorChangerDD>().customizerScript = this;
thisColorDropdown.GetComponent<CSColorChangerDD>().colorToChange = colorType.name;
thisColorDropdown.name = colorType.name + "DropdownHolder";
thisColorDropdown.transform.Find("SlotLabel").GetComponent<Text>().text = colorType.name + " Color";
thisColorDropdown.GetComponent<DropdownWithColor>().onValueChanged.AddListener(thisColorDropdown.GetComponent<CSColorChangerDD>().ChangeColor);
SetUpColorDropdownValue(thisColorDropdown.GetComponent<CSColorChangerDD>(), colorType);
}
}
foreach (CSColorChangerDD colorDropdown in colorDropdownPanel.transform.GetComponentsInChildren<CSColorChangerDD>())
{
bool keepOptionActive = false;
foreach (UMA.OverlayColorData ucd in umaData.umaRecipe.sharedColors)
{
if (colorDropdown.colorToChange == ucd.name)
{
keepOptionActive = true;
break;
}
}
if (!keepOptionActive)
{
colorDropdown.gameObject.SetActive(false);
}
}
}
19
Source : MacroPatterns.cs
with Apache License 2.0
from aaaddress1
with Apache License 2.0
from aaaddress1
public static List<String> ImportMacroPattern(List<string> macrosToImport)
{
List<string> importedMacros = new List<string>();
foreach (var macro in macrosToImport)
{
List<string> cellContent = macro.Split(";").ToList();
//Replace the single ; separator with an unlikely separator like ;;;;; since shellcode can contain a single ;
string importedMacro = string.Join(MacroColumnSeparator, cellContent.Select(ImportCellFormula));
importedMacros.Add(importedMacro);
}
return importedMacros;
}
19
Source : Program.cs
with Apache License 2.0
from aaaddress1
with Apache License 2.0
from aaaddress1
static void Main(string[] args)
{
Console.WriteLine(@" ====================================== ");
Console.WriteLine(@" xlsGen v1.0, by [email protected]");
Console.WriteLine(@" github.com/aaaddress1/xlsGen");
Console.WriteLine(@" ====================================== ");
Console.WriteLine();
var decoyDocPath = @"decoy_doreplacedent.xls";
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
List<BiffRecord> defaultMacroSheetRecords = GetDefaultMacroSheetRecords();
WorkbookStream wbs = LoadDecoyDoreplacedent(decoyDocPath);
Console.WriteLine(wbs.ToDisplayString()); // that'll be cool if there's a hex-print :)
List<string> sheetNames = wbs.GetAllRecordsByType<BoundSheet8>().Select(bs => bs.stName.Value).ToList();
List<string> preambleCode = new List<string>();
WorkbookEditor wbe = new WorkbookEditor(wbs);
var macroSheetName = "Sheet2";
wbe.AddMacroSheet(defaultMacroSheetRecords, macroSheetName, BoundSheet8.HiddenState.Visible);
List<string> macros = null;
byte[] binaryPayload = null;
int rwStart = 0, colStart = 2, dstRwStart = 0, dstColStart = 0;
int curRw = rwStart, curCol = colStart;
binaryPayload = File.ReadAllBytes("popcalc.bin");
wbe.SetMacroBinaryContent(binaryPayload, 0, dstColStart + 1, 0, 0, SheetPackingMethod.ObfuscatedCharFunc, PayloadPackingMethod.Base64);
curRw = wbe.WbStream.GetFirstEmptyRowInColumn(colStart) + 1;
macros = MacroPatterns.GetBase64DecodePattern(preambleCode);
//Orginal: wbe.SetMacroSheetContent(macros, 0, 2, dstRwStart, dstColStart, SheetPackingMethod.ObfuscatedCharFuncAlt);
macros.Add("=GOTO(R1C1)");
wbe.SetMacroSheetContent_NoLoader(macros, rwStart, colStart);
wbe.InitializeGlobalStreamLabels();
wbe.AddLabel("Auto_Open", rwStart, colStart);
#region save Workbook Stream to file
WorkbookStream createdWorkbook = wbe.WbStream;
ExcelDocWriter writer = new ExcelDocWriter();
string outputPath = "a.xls";
Console.WriteLine("Writing generated doreplacedent to {0}", outputPath);
writer.WriteDoreplacedent(outputPath, createdWorkbook, null);
#endregion
}
19
Source : FormulaHelper.cs
with Apache License 2.0
from aaaddress1
with Apache License 2.0
from aaaddress1
public static List<string> BuildBase64PayloadMacros(byte[] shellcode)
{
List<string> base64Strings = new List<string>();
//Base64 expansion is 4/3, and we have 252 bytes to spend, so we can have 189 bytes / cell
//As an added bonus, 189 is always divisible by 3, so we won't have == padding.
int maxBytesPerCell = 189;
for (int offset = 0; offset < shellcode.Length; offset += maxBytesPerCell)
{
byte[] guidShellcode;
if (shellcode.Length - offset < maxBytesPerCell)
{
guidShellcode = shellcode.Skip(offset).ToArray();
}
else
{
guidShellcode = shellcode.Skip(offset).Take(maxBytesPerCell).ToArray();
}
base64Strings.Add(Convert.ToBase64String(guidShellcode));
}
base64Strings.Add("END");
return base64Strings;
}
19
Source : Program.cs
with Apache License 2.0
from aaaddress1
with Apache License 2.0
from aaaddress1
static WorkbookEditor cmd_ModifySheet(WorkbookEditor wbe)
{
List<BoundSheet8> sheetList = wbe.WbStream.GetAllRecordsByType<BoundSheet8>();
log("\t[+] Detect {0} Sheets ...\n", ConsoleColor.Yellow, sheetList.Count);
for (int i = 0; i < sheetList.Count; i++)
log("\t\t[{0}] {1:s}\n", ConsoleColor.Yellow, i, sheetList[i].stName.Value);
log("\t[?] which one to hide (index): ", ConsoleColor.Yellow);
try
{
int indx = Convert.ToInt32(Console.ReadLine());
var replaceSheet = ((BiffRecord)sheetList[indx].Clone()).AsRecordType<BoundSheet8>();
replaceSheet.hsState = BoundSheet8.HiddenState.SuperVeryHidden;
wbe.WbStream = wbe.WbStream.ReplaceRecord(sheetList[indx], replaceSheet);
wbe.WbStream = wbe.WbStream.FixBoundSheetOffsets();
historyList.Add(string.Format("[#] History - Hide Sheet `{0}` done!\n", sheetList[indx].stName.Value));
}
catch { }
return wbe;
}
19
Source : BTCChinaAPI.cs
with MIT License
from aabiryukov
with MIT License
from aabiryukov
private string GetHMACSHA1Hash(NameValueCollection parameters)
{
var keyValues = new List<string>();
foreach (string key in parameters)
{
keyValues.Add(key + "=" + parameters[key]);
}
string input = String.Join("&", keyValues.ToArray());
//signature string for hash is NOT JSON-compatible
//watch out for API changes on the website.
input = input.Replace("\"", "");
input = input.Replace("true", "1");
input = input.Replace("false", "");
input = input.Replace("null", "");
//Console.WriteLine(input);
using (var hmacsha1 = new HMACSHA1(Encoding.ASCII.GetBytes(secretKey)))
{
byte[] hashData;
using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(input)))
{
hashData = hmacsha1.ComputeHash(stream);
}
// Format as hexadecimal string.
var hashBuilder = new StringBuilder();
foreach (byte data in hashData)
{
hashBuilder.Append(data.ToString("x2", CultureInfo.InvariantCulture));
}
return hashBuilder.ToString();
}
}
19
Source : TeamExplorerIntegrator.cs
with MIT License
from aabiryukov
with MIT License
from aabiryukov
public void SetSourceControlExplorerDirty(string serverPath)
{
m_dirtyPath.Add(serverPath);
}
19
Source : Database.cs
with Apache License 2.0
from aadreja
with Apache License 2.0
from aadreja
internal virtual bool CreateUpdateCommand(IDbCommand cmd, object enreplacedy, object oldEnreplacedy, IAuditTrail audit = null, string columnNames = null, bool doNotAppendCommonFields = false, bool overrideCreatedUpdatedOn = false)
{
bool isUpdateNeeded = false;
TableAttribute tableInfo = EnreplacedyCache.Get(enreplacedy.GetType());
if (!tableInfo.NoUpdatedBy && tableInfo.IsUpdatedByEmpty(enreplacedy))
throw new MissingFieldException("Updated By is required");
List<string> columns = new List<string>();
if (!string.IsNullOrEmpty(columnNames)) columns.AddRange(columnNames.Split(','));
else columns.AddRange(tableInfo.DefaultUpdateColumns);//Get columns from Enreplacedy attributes loaded in TableInfo
StringBuilder cmdText = new StringBuilder();
cmdText.Append($"UPDATE {tableInfo.FullName} SET ");
//add default columns if doesn't exists
if (!doNotAppendCommonFields)
{
if (!tableInfo.NoVersionNo && !columns.Contains(Config.VERSIONNO_COLUMN.Name))
columns.Add(Config.VERSIONNO_COLUMN.Name);
if (!tableInfo.NoUpdatedBy && !columns.Contains(Config.UPDATEDBY_COLUMN.Name))
columns.Add(Config.UPDATEDBY_COLUMN.Name);
if (!tableInfo.NoUpdatedOn && !columns.Contains(Config.UPDATEDON_COLUMN.Name))
columns.Add(Config.UPDATEDON_COLUMN.Name);
}
//remove primarykey, createdon and createdby columns if exists
columns.RemoveAll(c => tableInfo.PkColumnList.Select(p=>p.Name).Contains(c));
columns.RemoveAll(c => c == Config.CREATEDON_COLUMN.Name ||
c == Config.CREATEDBY_COLUMN.Name);
for (int i = 0; i < columns.Count(); i++)
{
if (columns[i].Equals(Config.VERSIONNO_COLUMN.Name, StringComparison.OrdinalIgnoreCase))
{
cmdText.Append($"{columns[i]} = {columns[i]}+1");
cmdText.Append(",");
}
else if (columns[i].Equals(Config.UPDATEDBY_COLUMN.Name, StringComparison.OrdinalIgnoreCase))
{
cmdText.Append($"{columns[i]} = @{columns[i]}");
cmdText.Append(",");
cmd.AddInParameter("@" + columns[i], Config.UPDATEDBY_COLUMN.ColumnDbType, tableInfo.GetUpdatedBy(enreplacedy));
}
else if (columns[i].Equals(Config.UPDATEDON_COLUMN.Name, StringComparison.OrdinalIgnoreCase))
{
var updatedOn = Helper.GetDateTimeOrDatabaseDateTimeSQL(tableInfo.GetUpdatedOn(enreplacedy), this, overrideCreatedUpdatedOn);
if (updatedOn is string)
{
cmdText.Append($"{columns[i]} = {CURRENTDATETIMESQL}");
}
else
{
cmdText.Append($"{columns[i]} = @{columns[i]}");
cmd.AddInParameter("@" + columns[i], Config.UPDATEDON_COLUMN.ColumnDbType, updatedOn);
}
cmdText.Append(",");
}
else
{
bool includeInUpdate = true;
tableInfo.Columns.TryGetValue(columns[i], out ColumnAttribute columnInfo); //find column attribute
DbType dbType = DbType.Object;
object columnValue = null;
if (columnInfo != null && columnInfo.GetMethod != null)
{
dbType = columnInfo.ColumnDbType;
columnValue = columnInfo.GetAction(enreplacedy);
includeInUpdate = oldEnreplacedy == null; //include in update when oldEnreplacedy not available
//compare with old object to check whether update is needed or not
object oldColumnValue = null;
if (oldEnreplacedy != null)
{
oldColumnValue = columnInfo.GetAction(oldEnreplacedy);
if (oldColumnValue != null && columnValue != null)
{
if (!oldColumnValue.Equals(columnValue)) //add to history only if property is modified
{
includeInUpdate = true;
}
}
else if (oldColumnValue == null && columnValue != null)
{
includeInUpdate = true;
}
else if (oldColumnValue != null)
{
includeInUpdate = true;
}
}
if (tableInfo.NeedsHistory && includeInUpdate) audit.AppendDetail(columns[i], columnValue, dbType, oldColumnValue);
}
if (includeInUpdate)
{
isUpdateNeeded = true;
cmdText.Append($"{columns[i]} = @{columns[i]}");
cmdText.Append(",");
cmd.AddInParameter("@" + columns[i], dbType, columnValue);
}
}
}
cmdText.RemoveLastComma(); //Remove last comma if exists
cmdText.Append(" WHERE ");
if (tableInfo.PkColumnList.Count > 1)
{
int index = 0;
foreach (ColumnAttribute pkCol in tableInfo.PkColumnList)
{
cmdText.Append($" {(index > 0 ? " AND " : "")} {pkCol.Name}=@{pkCol.Name}");
cmd.AddInParameter("@" + pkCol.Name, pkCol.ColumnDbType, tableInfo.GetKeyId(enreplacedy, pkCol));
index++;
}
}
else
{
cmdText.Append($" {tableInfo.PkColumn.Name}=@{tableInfo.PkColumn.Name}");
cmd.AddInParameter("@" + tableInfo.PkColumn.Name, tableInfo.PkColumn.ColumnDbType, tableInfo.GetKeyId(enreplacedy));
}
if (Config.DbConcurrencyCheck && !tableInfo.NoVersionNo)
{
cmdText.Append($" AND {Config.VERSIONNO_COLUMN.Name}=@{Config.VERSIONNO_COLUMN.Name}");
cmd.AddInParameter("@" + Config.VERSIONNO_COLUMN.Name, Config.VERSIONNO_COLUMN.ColumnDbType, tableInfo.GetVersionNo(enreplacedy));
}
cmd.CommandType = CommandType.Text;
cmd.CommandText = cmdText.ToString();
return isUpdateNeeded;
}
19
Source : PanelChat.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public void Drow(Rect inRect)
{
var iconWidth = 25f;
var iconWidthSpase = 30f;
/// -----------------------------------------------------------------------------------------
/// Список каналов
///
if (SessionClientController.Data.Chats != null)
{
lock (SessionClientController.Data.Chats)
{
if (SessionClientController.Data.ChatNotReadPost > 0) SessionClientController.Data.ChatNotReadPost = 0;
//Loger.Log("Client " + SessionClientController.Data.Chats.Count);
if (lbCannalsHeight == 0)
{
var textHeight = new DialogControlBase().TextHeight;
lbCannalsHeight = (float)Math.Round((decimal)(inRect.height / 2f / textHeight)) * textHeight;
}
Widgets.Label(new Rect(inRect.x, inRect.y + iconWidthSpase + lbCannalsHeight, 100f, 22f), "OCity_Dialog_Players".Translate());
if (lbCannals == null)
{
//первый запуск
lbCannals = new ListBox<string>();
lbCannals.Area = new Rect(inRect.x
, inRect.y + iconWidthSpase
, 100f
, lbCannalsHeight);
lbCannals.OnClick += (index, text) => DataLastChatsTime = DateTime.MinValue; /*StatusTemp = text;*/
lbCannals.SelectedIndex = 0;
}
if (lbPlayers == null)
{
//первый запуск
lbPlayers = new ListBox<ListBoxPlayerItem>();
lbPlayers.OnClick += (index, item) =>
{
//убираем выделение
lbPlayers.SelectedIndex = -1;
//вызываем контекстное меню
PlayerItemMenu(item);
};
lbPlayers.Tooltip = (item) => item.Tooltip;
}
if (PanelLastHeight != inRect.height)
{
PanelLastHeight = inRect.height;
lbPlayers.Area = new Rect(inRect.x
, inRect.y + iconWidthSpase + lbCannalsHeight + 22f
, 100f
, inRect.height - (iconWidthSpase + lbCannalsHeight + 22f));
}
if (NeedUpdateChat)
{
lbCannalsLastSelectedIndex = -1;
NeedUpdateChat = false;
}
var nowUpdateChat = DataLastChatsTime != SessionClientController.Data.ChatsTime.Time;
if (nowUpdateChat)
{
Loger.Log("Client UpdateChats nowUpdateChat");
DataLastChatsTime = SessionClientController.Data.ChatsTime.Time;
lbCannalsLastSelectedIndex = -1; //сброс для обновления содержимого окна
NeedUpdateChat = true;
}
if (nowUpdateChat
|| DataLastChatsTimeUpdateTime < DateTime.UtcNow.AddSeconds(-5))
{
DataLastChatsTimeUpdateTime = DateTime.UtcNow;
//пишем в лог
var updateLogHash = SessionClientController.Data.Chats.Count * 1000000
+ SessionClientController.Data.Chats.Sum(c => c.Posts.Count);
if (updateLogHash != UpdateLogHash)
{
UpdateLogHash = updateLogHash;
Loger.Log("Client UpdateChats chats="
+ SessionClientController.Data.Chats.Count.ToString()
+ " players=" + SessionClientController.Data.Players.Count.ToString());
}
//устанавливаем данные
lbCannals.DataSource = SessionClientController.Data.Chats
//.OrderBy(c => (c.OwnerMaker ? "2" : "1") + c.Name) нелья просто отсортировать, т.к. потом находим по индексу
.Select(c => c.Name)
.ToList();
if (lbCannalsGoToChat != null)
{
var lbCannalsGoToChatIndex = lbCannals.DataSource.IndexOf(lbCannalsGoToChat);
if (lbCannalsGoToChatIndex >= 0)
{
lbCannals.SelectedIndex = lbCannalsGoToChatIndex;
lbCannalsGoToChat = null;
}
}
//Заполняем список игроков по группами {
lbPlayers.DataSource = new List<ListBoxPlayerItem>();
var allreadyLogin = new List<string>();
Func<string, string, ListBoxPlayerItem> addPl = (login, text) =>
{
allreadyLogin.Add(login);
var n = new ListBoxPlayerItem()
{
Login = login,
Text = text,
Tooltip = login
};
lbPlayers.DataSource.Add(n);
return n;
};
Action<string> addreplaced = (text) =>
{
if (lbPlayers.DataSource.Count > 0) addPl(null, " ").Groupreplacedle = true;
addPl(null, " <i>– " + text + " –</i> ").Groupreplacedle = true;
};
Func<string, bool> isOnline = (login) => login == SessionClientController.My.Login
|| SessionClientController.Data.Players.ContainsKey(login) && SessionClientController.Data.Players[login].Online;
Func<bool, string, string> frameOnline = (online, txt) =>
online
? "<b>" + txt + "</b>"
: "<color=#888888ff>" + txt + "</color>";
if (lbCannals.SelectedIndex > 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
{
var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];
// в чате создатель
addreplaced("OCity_Dialog_Exchenge_Chat".Translate());
var n = addPl(selectCannal.OwnerLogin
, frameOnline(isOnline(selectCannal.OwnerLogin), "★ " + selectCannal.OwnerLogin));
n.Tooltip += "OCity_Dialog_ChennelOwn".Translate();
n.InChat = true;
// в чате
var offlinePartyLogin = new List<string>();
for (int i = 0; i < selectCannal.PartyLogin.Count; i++)
{
var lo = selectCannal.PartyLogin[i];
if (lo != "system" && lo != selectCannal.OwnerLogin)
{
if (isOnline(lo))
{
n = addPl(lo, frameOnline(true, lo));
n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
n.InChat = true;
}
else
offlinePartyLogin.Add(lo);
}
}
// в чате оффлайн
//addreplaced("оффлайн".Translate());
for (int i = 0; i < offlinePartyLogin.Count; i++)
{
var lo = offlinePartyLogin[i];
n = addPl(lo, frameOnline(false, lo));
n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
n.InChat = true;
}
}
var other = SessionClientController.Data.Chats[0].PartyLogin == null
? new List<string>()
: SessionClientController.Data.Chats[0].PartyLogin
.Where(p => p != "" && p != "system" && !allreadyLogin.Any(al => al == p))
.ToList();
if (other.Count > 0)
{
// игроки
addreplaced("OCity_Dialog_Exchenge_Gamers".Translate());
var offlinePartyLogin = new List<string>();
for (int i = 0; i < other.Count; i++)
{
var lo = other[i];
if (isOnline(lo))
{
var n = addPl(lo, frameOnline(true, lo));
//n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
}
else
offlinePartyLogin.Add(lo);
}
// игроки оффлайн
//addreplaced("оффлайн".Translate());
for (int i = 0; i < offlinePartyLogin.Count; i++)
{
var lo = offlinePartyLogin[i];
var n = addPl(lo, frameOnline(false, lo));
//n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
}
}
}
lbCannals.Drow();
lbPlayers.Drow();
var iconRect = new Rect(inRect.x, inRect.y, iconWidth, iconWidth);
TooltipHandler.TipRegion(iconRect, "OCity_Dialog_ChennelCreate".Translate());
if (Widgets.ButtonImage(iconRect, GeneralTexture.IconAddTex))
{
CannalAdd();
}
if (lbCannals.SelectedIndex > 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
{
//Если что-то выделено, и это не общий чат (строка 0)
iconRect.x += iconWidthSpase;
TooltipHandler.TipRegion(iconRect, "OCity_Dialog_ChennelClose".Translate());
if (Widgets.ButtonImage(iconRect, GeneralTexture.IconDelTex))
{
CannalDelete();
}
}
if (lbCannals.SelectedIndex >= 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
{
iconRect.x += iconWidthSpase;
TooltipHandler.TipRegion(iconRect, "OCity_Dialog_OthersFunctions".Translate());
if (Widgets.ButtonImage(iconRect, GeneralTexture.IconSubMenuTex))
{
CannalsMenuShow();
}
}
/// -----------------------------------------------------------------------------------------
/// Чат
///
if (lbCannalsLastSelectedIndex != lbCannals.SelectedIndex)
{
lbCannalsLastSelectedIndex = lbCannals.SelectedIndex;
if (lbCannals.SelectedIndex >= 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
{
var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];
if (selectCannal.Posts != null && selectCannal.Posts.Count > 0)
{
var chatLastPostTime = selectCannal.Posts.Max(p => p.Time);
if (ChatLastPostTime != chatLastPostTime)
{
ChatLastPostTime = chatLastPostTime;
Func<ChatPost, string> getPost = (cp) => "[" + cp.Time.ToGoodUtcString("dd HH:mm ") + cp.OwnerLogin + "]: " + cp.Message;
var totalLength = 0;
ChatBox.Text = selectCannal.Posts
.Reverse<ChatPost>()
.Where(i => (totalLength += i.Message.Length) < 5000)
.Aggregate("", (r, i) => getPost(i) + (r == "" ? "" : Environment.NewLine + r));
ChatScrollToDown = true;
}
//else ChatBox.Text = "";
}
//else ChatBox.Text = "";
}
else
ChatBox.Text = "";
}
if (lbCannals.SelectedIndex >= 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
{
var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];
var chatAreaOuter = new Rect(inRect.x + 110f, inRect.y, inRect.width - 110f, inRect.height - 30f);
ChatBox.Drow(chatAreaOuter, ChatScrollToDown);
ChatScrollToDown = false;
var rrect = new Rect(inRect.x + inRect.width - 25f, inRect.y + inRect.height - 25f, 25f, 25f);
Text.Font = GameFont.Medium;
Text.Anchor = TextAnchor.MiddleCenter;
Widgets.Label(rrect, "▶");
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.MiddleLeft;
bool rrcklick = Widgets.ButtonInvisible(rrect);
if (ChatInputText != "")
{
if (Mouse.IsOver(rrect))
{
Widgets.DrawHighlight(rrect);
}
var ev = Event.current;
if (ev.isKey && ev.type == EventType.KeyDown && ev.keyCode == KeyCode.Return
|| rrcklick)
{
//SoundDefOf.RadioButtonClicked.PlayOneShotOnCamera();
SessionClientController.Command((connect) =>
{
connect.PostingChat(selectCannal.Id, ChatInputText);
});
ChatInputText = "";
}
}
GUI.SetNextControlName("StartTextField");
ChatInputText = GUI.TextField(new Rect(inRect.x + 110f, inRect.y + inRect.height - 25f, inRect.width - 110f - 30f, 25f)
, ChatInputText, 10000);
if (NeedFockus)
{
NeedFockus = false;
GUI.FocusControl("StartTextField");
}
}
}
}
}
19
Source : ChatUtils.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public static List<string> SplitBySpace(string args)
{
int i = 0;
var argsM = new List<string>();
while (i + 1 < args.Length)
{
if (args[i] == '\'')
{
int endK = i;
bool exit;
do //запускаем поиск след кавычки снова, если после найденной ещё одна
{
exit = true;
endK = args.IndexOf('\'', endK + 1);
if (endK >= 0 && endK + 1 < args.Length && args[endK + 1] == '\'')
{
//это двойная кавычка - пропускаем её
endK++;
exit = false;
}
}
while (!exit);
if (endK >= 0)
{
argsM.Add(args.Substring(i + 1, endK - i - 1).Replace("''", "'"));
i = endK + 1;
continue;
}
}
var ni = args.IndexOf(" ", i);
if (ni >= 0)
{
//условие недобавления для двойного пробела
if (ni > i) argsM.Add(args.Substring(i, ni - i));
i = ni + 1;
continue;
}
else
{
break;
}
}
if (i < args.Length)
{
argsM.Add(args.Substring(i));
}
return argsM;
}
19
Source : Crypto.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public List<string> GetListPart(string source)
{
var list = new List<string>();
if (string.IsNullOrEmpty(source)) return list;
for (int i = 0; i <= source.Length / PartByteSize; i++)
{
var stradd =
//если последняя часть, то остаток строки
i == source.Length / PartByteSize
? source.Substring(i * PartByteSize)
: source.Substring(i * PartByteSize, PartByteSize);
if (!string.IsNullOrEmpty(stradd)) list.Add(stradd);
}
return list;
}
19
Source : Repository.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public static bool CheckIsBanIP(string IP)
{
if ((DateTime.UtcNow - BlockipUpdate).TotalSeconds > 30)
{
var fileName = Loger.PathLog + "blockip.txt";
BlockipUpdate = DateTime.UtcNow;
if (!File.Exists(fileName)) Blockip = new HashSet<string>();
else
try
{
var listBlock = File.ReadAllLines(fileName, Encoding.UTF8);
if (listBlock.Any(b => b.Contains("/")))
{
listBlock = listBlock
.SelectMany(b =>
{
var bb = b.Trim();
var comment = "";
var ic = bb.IndexOf(" ");
if (ic > 0)
{
comment = bb.Substring(ic);
bb = bb.Substring(0, ic);
}
if (bb.Any(c => !char.IsDigit(c) && c != '.' && c != '/')) return new List<string>();
var ls = bb.LastIndexOf("/");
if (ls < 0) return new List<string>() { bb + comment };
var lp = bb.LastIndexOf(".");
if (lp <= 0) return new List<string>();
var ib = int.Parse(bb.Substring(lp + 1, ls - (lp + 1)));
var ie = int.Parse(bb.Substring(ls + 1));
var res = new List<string>();
var s = bb.Substring(0, lp + 1);
for (int i = ib; i <= ie; i++)
res.Add(s + i.ToString() + comment);
return res;
})
.ToArray();
File.WriteAllLines(fileName, listBlock, Encoding.Default);
}
Blockip = new HashSet<string>(listBlock
.Select(b => b.Contains(" ") ? b.Substring(0, b.IndexOf(" ")) : b));
}
catch (Exception exp)
{
Loger.Log("CheckIsBanIP error " + exp.Message);
Blockip = new HashSet<string>();
return false;
}
}
return Blockip.Contains(IP.Trim());
}
19
Source : Dialog_CreateWorld.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
private string checkInvalidValue(bool isSeedErr, bool isScenarioErr, bool isDiffErr, bool isCoverageErr)
{
List<string> text = new List<string>();
if (isSeedErr)
{ text.Add("Seed"); }
if (isScenarioErr)
{ text.Add("Scenario"); }
if (isDiffErr)
{ text.Add("Difficulty"); }
if (isCoverageErr)
{ text.Add("Coverage"); }
return string.Join(", ", text);
}
19
Source : RepositorySaveData.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
private List<string> GetListPlayerFiles(string login)
{
var result = new List<string>();
var fileNameBase = GetFileNameBase(login);
for (int num = 1; num <= CountSaveDataPlayer; num++)
{
if (!File.Exists(fileNameBase + num.ToString())) break;
result.Add(fileNameBase + num.ToString());
}
if (result.Count == 0 && File.Exists(fileNameBase))
{
File.Move(fileNameBase, fileNameBase + "1");
result.Add(fileNameBase + "1");
}
return result;
}
19
Source : PanelChat.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public void Drow(Rect inRect)
{
var iconWidth = 25f;
var iconWidthSpase = 30f;
/// -----------------------------------------------------------------------------------------
/// Список каналов
///
if (SessionClientController.Data.Chats != null)
{
lock (SessionClientController.Data.Chats)
{
if (SessionClientController.Data.ChatNotReadPost > 0) SessionClientController.Data.ChatNotReadPost = 0;
//Loger.Log("Client " + SessionClientController.Data.Chats.Count);
if (lbCannalsHeight == 0)
{
var textHeight = new DialogControlBase().TextHeight;
lbCannalsHeight = (float)Math.Round((decimal)(inRect.height / 2f / textHeight)) * textHeight;
}
Widgets.Label(new Rect(inRect.x, inRect.y + iconWidthSpase + lbCannalsHeight, 100f, 22f), "OCity_Dialog_Players".Translate());
if (lbCannals == null)
{
//первый запуск
lbCannals = new ListBox<string>();
lbCannals.Area = new Rect(inRect.x
, inRect.y + iconWidthSpase
, 100f
, lbCannalsHeight);
lbCannals.OnClick += (index, text) => DataLastChatsTime = DateTime.MinValue; /*StatusTemp = text;*/
lbCannals.SelectedIndex = 0;
}
if (lbPlayers == null)
{
//первый запуск
lbPlayers = new ListBox<ListBoxPlayerItem>();
lbPlayers.OnClick += (index, item) =>
{
//убираем выделение
lbPlayers.SelectedIndex = -1;
//вызываем контекстное меню
PlayerItemMenu(item);
};
lbPlayers.Tooltip = (item) => item.Tooltip;
}
if (PanelLastHeight != inRect.height)
{
PanelLastHeight = inRect.height;
lbPlayers.Area = new Rect(inRect.x
, inRect.y + iconWidthSpase + lbCannalsHeight + 22f
, 100f
, inRect.height - (iconWidthSpase + lbCannalsHeight + 22f));
}
if (NeedUpdateChat)
{
lbCannalsLastSelectedIndex = -1;
NeedUpdateChat = false;
}
var nowUpdateChat = DataLastChatsTime != SessionClientController.Data.ChatsTime.Time;
if (nowUpdateChat)
{
Loger.Log("Client UpdateChats nowUpdateChat");
DataLastChatsTime = SessionClientController.Data.ChatsTime.Time;
lbCannalsLastSelectedIndex = -1; //сброс для обновления содержимого окна
NeedUpdateChat = true;
}
if (nowUpdateChat
|| DataLastChatsTimeUpdateTime < DateTime.UtcNow.AddSeconds(-5))
{
DataLastChatsTimeUpdateTime = DateTime.UtcNow;
//пишем в лог
var updateLogHash = SessionClientController.Data.Chats.Count * 1000000
+ SessionClientController.Data.Chats.Sum(c => c.Posts.Count);
if (updateLogHash != UpdateLogHash)
{
UpdateLogHash = updateLogHash;
Loger.Log("Client UpdateChats chats="
+ SessionClientController.Data.Chats.Count.ToString()
+ " players=" + SessionClientController.Data.Players.Count.ToString());
}
//устанавливаем данные
lbCannals.DataSource = SessionClientController.Data.Chats
//.OrderBy(c => (c.OwnerMaker ? "2" : "1") + c.Name) нелья просто отсортировать, т.к. потом находим по индексу
.Select(c => c.Name)
.ToList();
if (lbCannalsGoToChat != null)
{
var lbCannalsGoToChatIndex = lbCannals.DataSource.IndexOf(lbCannalsGoToChat);
if (lbCannalsGoToChatIndex >= 0)
{
lbCannals.SelectedIndex = lbCannalsGoToChatIndex;
lbCannalsGoToChat = null;
}
}
//Заполняем список игроков по группами {
lbPlayers.DataSource = new List<ListBoxPlayerItem>();
var allreadyLogin = new List<string>();
Func<string, string, ListBoxPlayerItem> addPl = (login, text) =>
{
allreadyLogin.Add(login);
var n = new ListBoxPlayerItem()
{
Login = login,
Text = text,
Tooltip = login
};
lbPlayers.DataSource.Add(n);
return n;
};
Action<string> addreplaced = (text) =>
{
if (lbPlayers.DataSource.Count > 0) addPl(null, " ").Groupreplacedle = true;
addPl(null, " <i>– " + text + " –</i> ").Groupreplacedle = true;
};
Func<string, bool> isOnline = (login) => login == SessionClientController.My.Login
|| SessionClientController.Data.Players.ContainsKey(login) && SessionClientController.Data.Players[login].Online;
Func<bool, string, string> frameOnline = (online, txt) =>
online
? "<b>" + txt + "</b>"
: "<color=#888888ff>" + txt + "</color>";
if (lbCannals.SelectedIndex > 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
{
var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];
// в чате создатель
addreplaced("OCity_Dialog_Exchenge_Chat".Translate());
var n = addPl(selectCannal.OwnerLogin
, frameOnline(isOnline(selectCannal.OwnerLogin), "★ " + selectCannal.OwnerLogin));
n.Tooltip += "OCity_Dialog_ChennelOwn".Translate();
n.InChat = true;
// в чате
var offlinePartyLogin = new List<string>();
for (int i = 0; i < selectCannal.PartyLogin.Count; i++)
{
var lo = selectCannal.PartyLogin[i];
if (lo != "system" && lo != selectCannal.OwnerLogin)
{
if (isOnline(lo))
{
n = addPl(lo, frameOnline(true, lo));
n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
n.InChat = true;
}
else
offlinePartyLogin.Add(lo);
}
}
// в чате оффлайн
//addreplaced("оффлайн".Translate());
for (int i = 0; i < offlinePartyLogin.Count; i++)
{
var lo = offlinePartyLogin[i];
n = addPl(lo, frameOnline(false, lo));
n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
n.InChat = true;
}
}
var other = SessionClientController.Data.Chats[0].PartyLogin == null
? new List<string>()
: SessionClientController.Data.Chats[0].PartyLogin
.Where(p => p != "" && p != "system" && !allreadyLogin.Any(al => al == p))
.ToList();
if (other.Count > 0)
{
// игроки
addreplaced("OCity_Dialog_Exchenge_Gamers".Translate());
var offlinePartyLogin = new List<string>();
for (int i = 0; i < other.Count; i++)
{
var lo = other[i];
if (isOnline(lo))
{
var n = addPl(lo, frameOnline(true, lo));
//n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
}
else
offlinePartyLogin.Add(lo);
}
// игроки оффлайн
//addreplaced("оффлайн".Translate());
for (int i = 0; i < offlinePartyLogin.Count; i++)
{
var lo = offlinePartyLogin[i];
var n = addPl(lo, frameOnline(false, lo));
//n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
}
}
}
lbCannals.Drow();
lbPlayers.Drow();
var iconRect = new Rect(inRect.x, inRect.y, iconWidth, iconWidth);
TooltipHandler.TipRegion(iconRect, "OCity_Dialog_ChennelCreate".Translate());
if (Widgets.ButtonImage(iconRect, GeneralTexture.IconAddTex))
{
CannalAdd();
}
if (lbCannals.SelectedIndex > 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
{
//Если что-то выделено, и это не общий чат (строка 0)
iconRect.x += iconWidthSpase;
TooltipHandler.TipRegion(iconRect, "OCity_Dialog_ChennelClose".Translate());
if (Widgets.ButtonImage(iconRect, GeneralTexture.IconDelTex))
{
CannalDelete();
}
}
if (lbCannals.SelectedIndex >= 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
{
iconRect.x += iconWidthSpase;
TooltipHandler.TipRegion(iconRect, "OCity_Dialog_OthersFunctions".Translate());
if (Widgets.ButtonImage(iconRect, GeneralTexture.IconSubMenuTex))
{
CannalsMenuShow();
}
}
/// -----------------------------------------------------------------------------------------
/// Чат
///
if (lbCannalsLastSelectedIndex != lbCannals.SelectedIndex)
{
lbCannalsLastSelectedIndex = lbCannals.SelectedIndex;
if (lbCannals.SelectedIndex >= 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
{
var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];
if (selectCannal.Posts != null && selectCannal.Posts.Count > 0)
{
var chatLastPostTime = selectCannal.Posts.Max(p => p.Time);
if (ChatLastPostTime != chatLastPostTime)
{
ChatLastPostTime = chatLastPostTime;
Func<ChatPost, string> getPost = (cp) => "[" + cp.Time.ToGoodUtcString("dd HH:mm ") + cp.OwnerLogin + "]: " + cp.Message;
var totalLength = 0;
ChatBox.Text = selectCannal.Posts
.Reverse<ChatPost>()
.Where(i => (totalLength += i.Message.Length) < 5000)
.Aggregate("", (r, i) => getPost(i) + (r == "" ? "" : Environment.NewLine + r));
ChatScrollToDown = true;
}
//else ChatBox.Text = "";
}
//else ChatBox.Text = "";
}
else
ChatBox.Text = "";
}
if (lbCannals.SelectedIndex >= 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
{
var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];
var chatAreaOuter = new Rect(inRect.x + 110f, inRect.y, inRect.width - 110f, inRect.height - 30f);
ChatBox.Drow(chatAreaOuter, ChatScrollToDown);
ChatScrollToDown = false;
var rrect = new Rect(inRect.x + inRect.width - 25f, inRect.y + inRect.height - 25f, 25f, 25f);
Text.Font = GameFont.Medium;
Text.Anchor = TextAnchor.MiddleCenter;
Widgets.Label(rrect, "▶");
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.MiddleLeft;
bool rrcklick = Widgets.ButtonInvisible(rrect);
if (ChatInputText != "")
{
if (Mouse.IsOver(rrect))
{
Widgets.DrawHighlight(rrect);
}
var ev = Event.current;
if (ev.isKey && ev.type == EventType.KeyDown && ev.keyCode == KeyCode.Return
|| rrcklick)
{
//SoundDefOf.RadioButtonClicked.PlayOneShotOnCamera();
SessionClientController.Command((connect) =>
{
connect.PostingChat(selectCannal.Id, ChatInputText);
});
ChatInputText = "";
}
}
GUI.SetNextControlName("StartTextField");
ChatInputText = GUI.TextField(new Rect(inRect.x + 110f, inRect.y + inRect.height - 25f, inRect.width - 110f - 30f, 25f)
, ChatInputText, 10000);
if (NeedFockus)
{
NeedFockus = false;
GUI.FocusControl("StartTextField");
}
}
}
}
}
19
Source : RepositorySaveData.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public void SavePlayerData(string login, byte[] data, bool single)
{
if (data == null || data.Length < 10) return;
var fileNameBase = GetFileNameBase(login);
var pFiles = GetListPlayerFiles(login);
if (single)
{
if (pFiles.Count > 0)
{
if (File.Exists(pFiles[0] + ".bak")) File.Delete(pFiles[0] + ".bak");
File.Move(pFiles[0], pFiles[0] + ".bak");
}
for (int i = 1; i < pFiles.Count; i++) File.Delete(pFiles[i]);
}
else
{
//Делаем так, чтобы в pFiles[pFiles.Count - 1] было имя файла которого нет
if (pFiles.Count == CountSaveDataPlayer)
{
File.Delete(pFiles[pFiles.Count - 1]);
}
else
{
pFiles.Add(fileNameBase + (pFiles.Count + 1).ToString());
}
for (int i = pFiles.Count - 2; i >= 0 ; i--)
{
File.Move(pFiles[i], pFiles[i + 1]);
}
}
var fileName = fileNameBase + "1";
byte[] dataToSave;
if (true)
{
dataToSave = GZip.ZipByteByte(data);
}
else
{
dataToSave = data;
}
File.WriteAllBytes(fileName, dataToSave);
Loger.Log("Server User " + Path.GetFileNameWithoutExtension(fileName) + " saved.");
}
19
Source : TestAppender.cs
with MIT License
from Abc-Arbitrage
with MIT License
from Abc-Arbitrage
public void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength)
{
if (_captureLoggedMessages)
LoggedMessages.Add(Encoding.ASCII.GetString(messageBytes, 0, messageLength));
if (++_messageCount == _messageCountTarget)
_signal.Set();
WaitOnWriteEvent?.Wait();
}
See More Examples