public void ApplyUndoData(UndoData undo) { // If the sprite isn't the same size (in tiles) as the undo data, resize it. if (undo.width * undo.height != m_tileWidth * m_tileHeight) { int nTiles = undo.width * undo.height; m_Tiles = new Tile[nTiles]; for (int i = 0; i < nTiles; i++) { m_Tiles[i] = new Tile(this, m_ss.NextTileId++); } } m_strName = undo.name; m_strDesc = undo.desc; SubpaletteID = undo.subpalette; m_tileWidth = undo.width; m_tileHeight = undo.height; for (int i = 0; i < NumTiles; i++) { m_Tiles[i].ApplyUndoData(undo.tiles[i]); } RecordSnapshot(); }
public TextEditWidget(string Text, RectDouble <T> bounds, T CapitalHeight) { Bounds = bounds; m_TextWidget = new TextWidget <T>(Text, M.Zero <T>(), M.Zero <T>(), CapitalHeight); AddChild(m_TextWidget); m_CharIndexToInsertBefore = Text.Length; IAffineTransformMatrix <T> transform = GetTransform(); IVector <T> v1 = transform.TransformVector(MatrixFactory <T> .CreateVector2D(bounds.x1, bounds.y1)); IVector <T> v2 = transform.TransformVector(MatrixFactory <T> .CreateVector2D(bounds.x2, bounds.y2)); SetTransform(transform); m_BorderSize = CapitalHeight.Multiply(.2); m_Thickness = CapitalHeight.Divide(8); m_CapsHeight = CapitalHeight; FixBarPosition(true); UndoData newUndoData = new UndoData(this); m_UndoBuffer.Add(newUndoData, "Initial", UndoBuffer.MergeType.NotMergable); }
public void UndoLastFileOperation() { if (undo.Count == 0) { MessageBox.Show("Nothing to undo...", "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } UndoData u = undo.Pop(); if (u.mode == UndoMode.Copy) { DeleteFile(u.dest, false); // delete copy of original file } else if (u.mode == UndoMode.Move) { AppSettings s = new AppSettings(); s.FileMode = FileOperations.Move; s.ExistingFiles = ExistingFileOptions.Overwrite; CopyMoveFile(u.dest, u.source, s, -1, false); // move back file } else if (u.mode == UndoMode.Rename) { RenameFile(u.dest, u.source, -1, false); // rename back to original filename } else if (u.mode == UndoMode.Delete) { Undelete(u.source); } mainForm.FileManagementCallback(new UndoCallbackData(UndoCallbackEvent.UndoPerformed, u)); }
public UndoData GetUndoData() { UndoData undo = new UndoData(); RecordUndoData(ref undo); return(undo); }
void RunUndoRollback(UndoData u) { this.ProcsScript = EventScript.CloneEventList(u.EventAsm); //リストの更新. this.Script.DummyAlloc(this.ProcsScript.Count, this.Script.SelectedIndex); }
public void Init(Document doc, Spriteset ss, int nWidth, int nHeight, string strName, int id, string strDesc, int nSubpalette) { m_doc = doc; m_ss = ss; if (strName == "" || ss.HasNamedSprite(strName) ) { strName = ss.AutoGenerateSpriteName(); } m_strName = strName; m_strDesc = strDesc; SubpaletteID = nSubpalette; m_tileWidth = nWidth; m_tileHeight = nHeight; int nTiles = NumTiles; m_Tiles = new Tile[nTiles]; for (int i = 0; i < nTiles; i++) { m_Tiles[i] = new Tile(this, ss.NextTileId++); } // Make an initial snapshot of the (empty) sprite. m_snapshot = GetUndoData(); }
public override void OnKeyPress(KeyPressEventArgs keyPressEvent) { if (m_Selecting) { DeleteSelection(); m_Selecting = false; } StringBuilder tempString = new StringBuilder(m_TextWidget.Text); tempString.Insert(m_CharIndexToInsertBefore, keyPressEvent.KeyChar); keyPressEvent.Handled = true; m_CharIndexToInsertBefore++; m_TextWidget.Text = tempString.ToString(); base.OnKeyPress(keyPressEvent); FixBarPosition(true); UndoData newUndoData = new UndoData(this); if (m_CharIndexToAcceptAsMerging == m_CharIndexToInsertBefore - 1 && keyPressEvent.KeyChar != '\r') { m_UndoBuffer.Add(newUndoData, "Typing", UndoBuffer.MergeType.Mergable); } else { m_UndoBuffer.Add(newUndoData, "Typing", UndoBuffer.MergeType.NotMergable); } m_CharIndexToAcceptAsMerging = m_CharIndexToInsertBefore; }
//メモリ上だけでのUndo public static byte[] RollbackMemoryData(Undo u, int pos, byte[] romdata) { byte[] ret = (byte[])romdata.Clone(); //undoの実行 for (int i = u.UndoBuffer.Count - 1; i >= pos; i--) { UndoData ud = u.UndoBuffer[i]; if (ret.Length < ud.filesize) {//ROMサイズが増やさないといけないなら増やす. Array.Resize(ref ret, (int)U.Padding4(ud.filesize)); } for (int n = 0; n < ud.list.Count; n++) { U.write_range(ret, ud.list[n].addr, ud.list[n].data); } if (ret.Length > ud.filesize) {//ROMサイズを減らさないといけないなら、ここで減らす. Array.Resize(ref ret, (int)U.Padding4(ud.filesize)); } } return(ret); }
void RunUndoRollback(UndoData u) { this.LockWindowUpdate(); this.Text = u.Text; this.UnLockWindowUpdate(); this.SelectionStart = u.SelectionStart; }
public Map(Document doc, string strName, int id, string strDesc, Spriteset bgtiles) { m_doc = doc; m_ss = bgtiles; m_ss.AddMap(this); m_strName = strName; m_id = id; m_strDesc = strDesc; m_BackgroundMap = new BackgroundMapTileInfo[kMaxMapTilesX, kMaxMapTilesY]; int nDefaultTile = -1; if (bgtiles.CurrentSprite != null) nDefaultTile = bgtiles.CurrentSprite.FirstTileId; for (int ix = 0; ix < kMaxMapTilesX; ix++) for (int iy = 0; iy < kMaxMapTilesY; iy++) { m_BackgroundMap[ix, iy].nTileIndex = nDefaultTile; m_BackgroundMap[ix, iy].nSubpalette = 0; } // Make an initial snapshot of the (empty) map. m_snapshot = GetUndoData(); if (m_doc.Owner != null) { m_winMap = new MapForm(m_doc.Owner, this, bgtiles, null); ; } }
public void WhenIUndoEventsTheyAreUndone(IEventDataDeserializationService eventDataDeserializationService) { var target = new UndoEventProcessingService(eventDataDeserializationService); var eventDataSerialized = Guid.NewGuid().ToString(); var fixture = new Fixture().Customize(new AutoConfiguredNSubstituteCustomization()); fixture.Register(() => false); var events = fixture.CreateMany <IEvent>(4).OrderBy(t => t.EffectiveDateTime).ToList(); var undoEvent = Substitute.For <IEvent>(); var eventData = new UndoData(events.Select(t => t.EventId).ToList()); var latestEvent = events.Max(t => t.EffectiveDateTime).AddSeconds(1); var expectedToBeUndone = new List <IEvent>(); expectedToBeUndone.AddRange(events); undoEvent.EventType.Name.Returns("Undo"); undoEvent.EventData.Returns(eventDataSerialized); undoEvent.EffectiveDateTime.Returns(latestEvent); events.Add(undoEvent); eventDataDeserializationService.Deserialize(typeof(UndoData), eventDataSerialized).Returns(eventData); target.Execute(events); Assert.All(expectedToBeUndone, @event => @event.Received().Undone = true); }
public UndoData GetUndoData() { UndoData undo = new UndoData(m_tileWidth, m_tileHeight); RecordUndoData(ref undo); return(undo); }
public Map(Document doc, string strName, int id, string strDesc, Spriteset bgtiles) { m_doc = doc; m_ss = bgtiles; m_ss.AddMap(this); m_strName = strName; m_id = id; m_strDesc = strDesc; m_BackgroundMap = new BackgroundMapTileInfo[kMaxMapTilesX, kMaxMapTilesY]; int nDefaultTile = -1; if (bgtiles.CurrentSprite != null) { nDefaultTile = bgtiles.CurrentSprite.FirstTileId; } for (int ix = 0; ix < kMaxMapTilesX; ix++) { for (int iy = 0; iy < kMaxMapTilesY; iy++) { m_BackgroundMap[ix, iy].nTileIndex = nDefaultTile; m_BackgroundMap[ix, iy].nSubpalette = 0; } } // Make an initial snapshot of the (empty) map. m_snapshot = GetUndoData(); if (m_doc.Owner != null) { m_winMap = new MapForm(m_doc.Owner, this, bgtiles, null);; } }
public void UndoLastFileOperation() { bool bContinue = true; string errors = ""; string lastItemGroup = "unset"; if (undo.Count == 0) { MessageBox.Show(_("Nothing to undo..."), _("Oops"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } bool stopGoto = false; int num = 0; string oldCurPath = mainForm.GetCurPicPath(); // CurPath must be no duplicates while (bContinue) { if (undo.Count == 0 || lastItemGroup != "unset" && lastItemGroup != undo.Peek().actionGroup) // Assume that batch data is continuous { if (stopGoto && num > 0) // Refresh when undoing a batch of deletions, keep in current picture. { mainForm.PicGotoCallback(-1, oldCurPath); } break; // emptied or this is new undo group } UndoData u = undo.Pop(); lastItemGroup = u.actionGroup; if (u.mode == UndoMode.Copy) { DeleteFile(u.dest, false); // delete copy of original file } else if (u.mode == UndoMode.Move) { AppSettings s = new AppSettings(); s.FileMode = FileOperations.Move; s.ExistingFiles = ExistingFileOptions.Overwrite; errors += CopyMoveFile(u.dest, u.source, s, -1, false) + "\n"; // move back file } else if (u.mode == UndoMode.Rename) { RenameFile(u.dest, u.source, -1, false); // rename back to original filename } else if (u.mode == UndoMode.Delete) { Undelete(u.source); stopGoto = true; // better performance for a batch } num++; mainForm.FileManagementCallback(new UndoCallbackData(UndoCallbackEvent.UndoPerformed, u), stopGoto); } if (!string.IsNullOrWhiteSpace(errors)) { MessageBox.Show("Error copying/moving file: \n\n" + errors, "File Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void ApplyUndoData(UndoData undo) { for (int iRow = 0; iRow < TileSize; iRow++) { for (int iColumn = 0; iColumn < TileSize; iColumn++) SetPixel(iColumn, iRow, undo.pixels[iColumn, iRow]); } }
public Tile(Sprite s, int nTileId) { m_sprite = s; m_id = nTileId; m_data = new UndoData(TileSize); // This will be assigned when the spriteset is saved or exported. m_nExportId = 0; }
void RunUndoRollback(UndoData u) { this.ProcsScript = EventScript.CloneEventList(u.EventAsm); //最後に自下げ処理実行. EventScriptUtil.JisageReorder(this.ProcsScript); //リストの更新. this.Script.DummyAlloc(this.ProcsScript.Count, this.Script.SelectedIndex); }
public Tile(Sprite s, int nTileId) { m_sprite = s; m_id = nTileId; m_data = new UndoData(TileSize); // This will be assigned when the spriteset is saved or exported. m_nExportId = 0; }
public void ApplyUndoData(UndoData undo) { for (int iRow = 0; iRow < TileSize; iRow++) { for (int iColumn = 0; iColumn < TileSize; iColumn++) { SetPixel(iColumn, iRow, undo.pixels[iColumn, iRow]); } } }
private void AddToUndo(string SourceFilename, string DestFilename, UndoMode mode, int picIndex) { UndoData u = new UndoData(); u.source = SourceFilename; u.dest = DestFilename; u.mode = mode; u.picIndex = picIndex; undo.Push(u); mainForm.FileManagementCallback(new UndoCallbackData(UndoCallbackEvent.UndoUpdated, u)); }
UndoData NewUndoDataLow(string name) { UndoData ud = new UndoData(); ud.time = DateTime.Now.ToLocalTime(); ud.name = name; ud.list = new List <UndoPostion>(); ud.filesize = (uint)Program.ROM.Data.Length; return(ud); }
public UndoData(UndoData data) { tilesize = data.tilesize; pixels = new int[tilesize, tilesize]; for (int iRow = 0; iRow < tilesize; iRow++) { for (int iColumn = 0; iColumn < tilesize; iColumn++) { pixels[iColumn, iRow] = data.pixels[iColumn, iRow]; } } }
void PushUndo() { if (this.UndoPosstion < this.UndoBuffer.Count) {//常に先頭に追加したいので、リスト中に戻っている場合は、それ以降を消す. this.UndoBuffer.RemoveRange(this.UndoPosstion, this.UndoBuffer.Count - this.UndoPosstion); } UndoData p = new UndoData(); p.EventAsm = EventScript.CloneEventList(this.ProcsScript); this.UndoBuffer.Add(p); this.UndoPosstion = this.UndoBuffer.Count; }
void RunUndoRollback(UndoData u, bool isUndo) { if (isUndo) { this.Data[u.addr] = u.orignal; } else { this.Data[u.addr] = u.newvalue; } this.JumpTo(u.addr, false); }
public void PushUndo() { if (this.UndoPosstion < this.UndoBuffer.Count) {//常に先頭に追加したいので、リスト中に戻っている場合は、それ以降を消す. this.UndoBuffer.RemoveRange(this.UndoPosstion, this.UndoBuffer.Count - this.UndoPosstion); } UndoData p = new UndoData(); p.Text = this.Text; p.SelectionStart = this.SelectionStart; this.UndoBuffer.Add(p); this.UndoPosstion = this.UndoBuffer.Count; }
void PushUndo() { if (this.UndoPosstion < this.UndoBuffer.Count) {//常に先頭に追加したいので、リスト中に戻っている場合は、それ以降を消す. this.UndoBuffer.RemoveRange(this.UndoPosstion, this.UndoBuffer.Count - this.UndoPosstion); } UndoData p = new UndoData(); p.MAR = ClonePathList(this.PathList); this.UndoBuffer.Add(p); this.UndoPosstion = this.UndoBuffer.Count; }
public UndoData GetUndoData() { UndoData undo = new UndoData(TileSize); for (int iRow = 0; iRow < TileSize; iRow++) { for (int iColumn = 0; iColumn < TileSize; iColumn++) { undo.pixels[iColumn, iRow] = GetPixel(iColumn, iRow); } } return(undo); }
void PushUndo(uint addr, byte newvalue, byte orignal) { if (this.UndoPosstion < this.UndoBuffer.Count) {//常に先頭に追加したいので、リスト中に戻っている場合は、それ以降を消す. this.UndoBuffer.RemoveRange(this.UndoPosstion, this.UndoBuffer.Count - this.UndoPosstion); } UndoData p = new UndoData(); p.addr = addr; //アドレス p.newvalue = newvalue; //新値 p.orignal = orignal; //元値 this.UndoBuffer.Add(p); this.UndoPosstion = this.UndoBuffer.Count; }
public void Push(string name, uint addr, uint size) { UndoData ud = new UndoData(); ud.time = DateTime.Now.ToLocalTime(); ud.name = name; ud.list = new List <UndoPostion>(); ud.filesize = (uint)Program.ROM.Data.Length; UndoPostion up = new UndoPostion(addr, size); ud.list.Add(up); Push(ud); }
public UndoData(UndoData data) { subpalette = data.subpalette; name = data.name; desc = data.desc; width = data.width; height = data.height; int nTiles = width * height; tiles = new Tile.UndoData[nTiles]; for (int i = 0; i < nTiles; i++) { tiles[i] = new Tile.UndoData(data.tiles[i]); } }
public UndoData(UndoData data) { name = data.name; desc = data.desc; width = data.width; height = data.height; map = new BackgroundMapTileInfo[width, height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { map[x, y] = data.map[x, y]; } } }
void Patch(UndoData ud, ROM rom) { if (rom.Data.Length < ud.filesize) {//ROMサイズが増やさないといけないなら増やす. rom.write_resize_data(ud.filesize); } for (int i = 0; i < ud.list.Count; i++) { rom.write_range(ud.list[i].addr, ud.list[i].data); } if (rom.Data.Length > ud.filesize) {//ROMサイズを減らさないといけないなら、ここで減らす. rom.write_resize_data(ud.filesize); } }
public void PushUndo() { if (UndoLock) { return; } if (this.UndoPosstion < this.UndoBuffer.Count) {//常に先頭に追加したいので、リスト中に戻っている場合は、それ以降を消す. this.UndoBuffer.RemoveRange(this.UndoPosstion, this.UndoBuffer.Count - this.UndoPosstion); } UndoData p = new UndoData(); p.PaletteBIN = MakePaletteUIToByte_OldValue(); this.UndoBuffer.Add(p); this.UndoPosstion = this.UndoBuffer.Count; }
public UndoData GetUndoData() { UndoData undo = new UndoData(); RecordUndoData(ref undo); return undo; }
public bool Equals(UndoData data) { if (subpalette != data.subpalette || name != data.name || desc != data.desc || width != data.width || height != data.height ) return false; int nTiles = width * height; for (int i = 0; i < nTiles; i++) if (!tiles[i].Equals(data.tiles[i])) return false; return true; }
private void RecordUndoData(ref UndoData undo) { undo.name = m_strName; undo.desc = m_strDesc; undo.width = kMaxMapTilesX; undo.height = kMaxMapTilesY; for (int y = 0; y < kMaxMapTilesY; y++) { for (int x = 0; x < kMaxMapTilesX; x++) { undo.map[x, y].nTileIndex = m_BackgroundMap[x, y].nTileIndex; undo.map[x, y].nSubpalette = m_BackgroundMap[x, y].nSubpalette; undo.map[x, y].fHFlip = m_BackgroundMap[x, y].fHFlip; undo.map[x, y].fVFlip = m_BackgroundMap[x, y].fVFlip; } } }
public UndoData(UndoData data) { name = data.name; desc = data.desc; width = data.width; height = data.height; map = new BackgroundMapTileInfo[width, height]; for (int y=0; y < height; y++) for (int x = 0; x < width; x++) map[x,y] = data.map[x,y]; }
public UndoData GetUndoData() { UndoData undo = new UndoData(TileSize); for (int iRow = 0; iRow < TileSize; iRow++) { for (int iColumn = 0; iColumn < TileSize; iColumn++) undo.pixels[iColumn, iRow] = GetPixel(iColumn, iRow); } return undo; }
private void RecordUndoData(ref UndoData undo) { // If the given undo struct isn't the right size, resize it. if (undo.width * undo.height != m_tileWidth * m_tileHeight) undo = new UndoData(m_tileWidth, m_tileHeight); undo.name = m_strName; undo.desc = m_strDesc; undo.subpalette = SubpaletteID; undo.width = m_tileWidth; undo.height = m_tileHeight; int nTiles = NumTiles; for (int i = 0; i < nTiles; i++) undo.tiles[i] = m_Tiles[i].GetUndoData(); }
void SubmitSolutionAndReload(TimeSpan time) { greenCount = 0; originalGreenCount = 0; currentX = 0; currentY = 0; nextFootPrint = 3; testGrid.Delete(); currentMoveList.Clear(); GetLevel(solutionURL); solved = false; linesMade = false; currentStartX = 0; currentStartY = 0; Reset(); undoData = new UndoData(system, sizeY); }
public void ApplyUndoData(UndoData undo) { // If the sprite isn't the same size (in tiles) as the undo data, resize it. if (undo.width * undo.height != m_tileWidth * m_tileHeight) { int nTiles = undo.width * undo.height; m_Tiles = new Tile[nTiles]; for (int i = 0; i < nTiles; i++) m_Tiles[i] = new Tile(this, m_ss.NextTileId++); } m_strName = undo.name; m_strDesc = undo.desc; SubpaletteID = undo.subpalette; m_tileWidth = undo.width; m_tileHeight = undo.height; for (int i = 0; i < NumTiles; i++) m_Tiles[i].ApplyUndoData(undo.tiles[i]); RecordSnapshot(); }
/// <summary> /// Change Character Configuration using JSON string Array<Dictionary> /// </summary> /// <param name="content">JSON array of dictionary</param> /// <returns>true if valid, false otherwise</returns> public bool ChangeCharacterFromJSON(string content) { if (content == "") { return false; } string json = content; List<Dictionary<string, string>> jsonValues = null; try { jsonValues = JsonMapper.ToObject<List<Dictionary<string, string>>>(json); //TODOCHECK //jsonValues = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(json); } catch (Exception ex) { Debug.LogError("Error on JsonConvert Array: " + ex.Message); return false; } bool result = false; if (jsonValues != null) { CharacterConfig config = new CharacterConfig(); ///*********** SAVE UNDO HERE ************************/ if (currentCharacterConfig != null) { var undo = currentCharacterConfig.CharacterConfigToJson(SkinColorIndex, IsUseHat); Debug.LogWarning("saving undo: " + undo); UndoData data = new UndoData(UndoType.Character, undo); undoStacks.Push(data); } currentCharacterConfig = config; ///***************************************************/ foreach (Dictionary<string, string> map in jsonValues) { if (map.ContainsKey("tipe") == false) { continue; } string tipe = map["tipe"]; if (tipe.ToLower() == "gender") { config.characterBase = map["element"]; } else if (tipe.ToLower() == "skin") { if (map.ContainsKey("color")) { string color = map["color"]; if (string.IsNullOrEmpty(color) || color.ToLower() == "nan") { color = "1"; } _skinColorIndex = Int32.Parse(color); } } else { CharacterConstants.BodyPart bodyPart = (CharacterConstants.BodyPart)Enum.Parse(typeof(CharacterConstants.BodyPart), tipe, true); string element = map["element"]; string id = map.ContainsKey("id") ? map["id"] : ""; if (bodyPart == CharacterConstants.BodyPart.Face) { // Only for face string eyeBrows = map["eye_brows"]; string eyes = map["eyes"]; string lip = map["lip"]; config.face = element; config.eyeBrows = eyeBrows; config.eyes = eyes; config.lip = lip; config.faceId = id; } else { string material = map["material"]; switch (bodyPart) { case CharacterConstants.BodyPart.Hat: config.hatId = id; config.hat = element; config.hatMaterial = material; break; case CharacterConstants.BodyPart.Hair: config.hairId = id; config.hair = element; config.hairMaterial = material; break; case CharacterConstants.BodyPart.Face: config.faceId = id; config.face = element; config.faceMaterial = material; break; case CharacterConstants.BodyPart.Body: config.bodyId = id; config.body = element; config.bodyMaterial = material; break; case CharacterConstants.BodyPart.Pants: config.pantsId = id; config.pants = element; config.pantsMaterial = material; break; case CharacterConstants.BodyPart.Shoes: config.shoesId = id; config.shoes = element; config.shoesMaterial = material; break; case CharacterConstants.BodyPart.Hand: config.handId = id; config.hand = element; config.handMaterial = material; break; case CharacterConstants.BodyPart.HairBottom: config.hairBottomId = id; config.hairBottom = element; config.hairBottomMaterial = material; break; } } } } ChangeCharacter(config); result = true; //Debug.LogWarning(config.CharacterConfigToJson(SkinColorIndex, IsUseHat)); } return result; }
public UndoData GetUndoData() { UndoData undo = new UndoData(m_tileWidth, m_tileHeight); RecordUndoData(ref undo); return undo; }
/// <summary> /// Change Character Element using JSON string: Dictionary /// </summary> /// <param name="content">JSON dictionary</param> /// <returns>true if valid, false otherwise</returns> public bool ChangeElementFromJSON(string content) { if (content == "") { return false; } Dictionary<string, string> jsonValues = null; try { jsonValues = JsonMapper.ToObject<Dictionary<string, string>>(content); //TODOCHECK //jsonValues = JsonConvert.DeserializeObject<Dictionary<string, string>>(content); } catch (Exception ex) { Debug.LogError("CharacterGenerator: Error On JsonConvert: " + ex.Message); return false; } bool result = false; if (jsonValues != null) { // If we don't find "tipe" key, then we are not dealing with correct json dictionary, bug out -SA if (jsonValues.ContainsKey("tipe") == false) { return false; } IsUseHat = false; string tipe = jsonValues["tipe"]; // Get list of BodyPart enums to compare to, we can change this into better codes string[] bodyParts = Enum.GetNames(typeof(CharacterConstants.BodyPart)); foreach (string part in bodyParts) { // If we have a match of "tipe" key, then we're good to go if (tipe.ToLower() == part.ToLower()) { // Get the part type CharacterConstants.BodyPart bodyPart = (CharacterConstants.BodyPart)Enum.Parse(typeof(CharacterConstants.BodyPart), part, true); /* {'gender':'male','tipe':'face','element':'male_head','material':''} */ string element = jsonValues["element"]; string material = jsonValues["material"]; if (bodyPart == CharacterConstants.BodyPart.Face) { ChangeFaceElement(element, jsonValues["eye_brows"], jsonValues["eyes"], jsonValues["lip"]); } else { string undoJson = currentCharacterConfig.BodyPartConfigToJson(bodyPart); UndoData undo = new UndoData(UndoType.Element, undoJson); undoStacks.Push(undo); // Change the element and the material ChangeElement(bodyPart, element, material); } result = true; break; } } // If this is not body part, check if this is a face part if (!result) { result = ChangeFacePartFromJSON(content); } } return result; }
public void Init(Document doc, Spriteset ss, int nWidth, int nHeight, string strName, int id, string strDesc, int nSubpalette) { m_doc = doc; m_ss = ss; if (strName == "" || ss.HasNamedSprite(strName) ) strName = ss.AutoGenerateSpriteName(); m_strName = strName; m_strDesc = strDesc; SubpaletteID = nSubpalette; m_tileWidth = nWidth; m_tileHeight = nHeight; int nTiles = NumTiles; m_Tiles = new Tile[nTiles]; for (int i=0; i < nTiles; i++) m_Tiles[i] = new Tile(this, ss.NextTileId++); // Make an initial snapshot of the (empty) sprite. m_snapshot = GetUndoData(); }
/// <summary> /// Change face part from json string /// </summary> /// <param name="content">json dictionary</param> /// <returns>true if succeed, false otherwise</returns> public bool ChangeFacePartFromJSON(string content) { if (content == "") { return false; } Dictionary<string, string> jsonValues = null; try { jsonValues = JsonMapper.ToObject<Dictionary<string, string>>(content); } catch (Exception ex) { Debug.LogError("Error On JsonConvert: " + ex.Message); return false; } bool result = false; if (jsonValues != null) { // If we don't find "tipe" key, then we are not dealing with correct json dictionary, bug out -SA if (jsonValues.ContainsKey("tipe") == false) { return false; } string tipe = jsonValues["tipe"]; // Get list of BodyPart enums to compare to, we can change this into better codes string[] parts = Enum.GetNames(typeof(CharacterConstants.FacePart)); foreach (string part in parts) { // If we have a match of "tipe" key, then we're good to go if (tipe.ToLower() == part.ToLower()) { // Get the part type CharacterConstants.FacePart facePart = (CharacterConstants.FacePart)Enum.Parse(typeof(CharacterConstants.FacePart), part, true); // Save the Undo string undoJson = currentCharacterConfig.FacePartConfigToJson(facePart); UndoData undo = new UndoData(UndoType.Facial, undoJson); undoStacks.Push(undo); ChangeFacePart(facePart, jsonValues["element"]); result = true; break; } } } return result; }
public void ApplyUndoData(UndoData undo) { m_strName = undo.name; m_strDesc = undo.desc; //width = undo.width; //height = undo.height; for (int y = 0; y < kMaxMapTilesY; y++) { for (int x = 0; x < kMaxMapTilesX; x++) { m_BackgroundMap[x, y].nTileIndex = undo.map[x, y].nTileIndex; m_BackgroundMap[x, y].nSubpalette = undo.map[x, y].nSubpalette; m_BackgroundMap[x, y].fHFlip = undo.map[x, y].fHFlip; m_BackgroundMap[x, y].fVFlip = undo.map[x, y].fVFlip; } } RecordSnapshot(); }
public bool Equals(UndoData data) { if (tilesize != data.tilesize) return false; for (int iRow = 0; iRow < tilesize; iRow++) for (int iColumn = 0; iColumn < tilesize; iColumn++) if (pixels[iColumn, iRow] != data.pixels[iColumn, iRow]) return false; return true; }
/*//////////////////////////////////////////////////////// Methods ////////////////////////////////////////////////////////*/ public override void Initialize() { base.Initialize(); /*///////////////////////////////// Settings /////////////////////////////////*/ #region initsettings graphics.Settings.Display.VSyncEnabled.ClientValue = false; graphics.Settings.Projection.ProjectionType.ClientValue = projectionType; graphics.Settings.Projection.OrthographicBoundary.ClientValue = new Rectangle(0f, 8f, 0f, 6f); graphics.Settings.Projection.OrthographicBoundary.UpdateRateHolding.ClientValue = 0.5f; System.Window.Title = "Client"; System.Graphics.Settings.ScreenArea.WindowSize.ClientVector2D = new Vector2(800f, 600f); double g = graphics.Settings.Projection.ZNear.ClientValue = 1.0; double f = graphics.Settings.Projection.ZFar.ClientValue = 19.001; GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Less); GL.CullFace(CullFaceMode.FrontAndBack); GL.Hint(HintTarget.FogHint, HintMode.Fastest); GL.Hint(HintTarget.GenerateMipmapHint, HintMode.Fastest); GL.Hint(HintTarget.LineSmoothHint, HintMode.Fastest); GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Fastest); GL.Hint(HintTarget.PointSmoothHint, HintMode.Fastest); GL.Hint(HintTarget.PolygonSmoothHint, HintMode.Fastest); GL.Hint(HintTarget.TextureCompressionHint, HintMode.Fastest); #endregion /*///////////////////////////////// Buttons /////////////////////////////////*/ #region initbuttons ButtonMapping bMap = System.Input.Settings.ButtonMapSettings.CurrentButtonMap; //Zoom/Pan bMap.AddHotkey(CommonKeyboardKeys.NUMPAD_ADD, FACESystemFunctions.Projection_Ortho_ZoomIn, ButtonMapType.Holding); bMap.AddHotkey(CommonKeyboardKeys.NUMPAD_SUBTRACT, FACESystemFunctions.Projection_Ortho_ZoomOut, ButtonMapType.Holding); bMap.AddHotkey(CommonKeyboardKeys.NUMPAD8, FACESystemFunctions.Projection_Ortho_MoveUp, ButtonMapType.Holding); bMap.AddHotkey(CommonKeyboardKeys.NUMPAD2, FACESystemFunctions.Projection_Ortho_MoveDown, ButtonMapType.Holding); bMap.AddHotkey(CommonKeyboardKeys.NUMPAD4, FACESystemFunctions.Projection_Ortho_MoveLeft, ButtonMapType.Holding); bMap.AddHotkey(CommonKeyboardKeys.NUMPAD6, FACESystemFunctions.Projection_Ortho_MoveRight, ButtonMapType.Holding); bMap.AddHotkey(CommonKeyboardKeys.T, new TimeDependentFunction(SubmitSolutionAndReload), ButtonMapType.JustPressed); bMap.AddHotkey(CommonKeyboardKeys.D, new TimeDependentFunction(ToggleBoardDrawing), ButtonMapType.JustPressed); #endregion /*///////////////////////////////// Data /////////////////////////////////*/ #region initdata greenBox = new Texture2D(@"../../Content/greensquare.bmp"); greyBox = new Texture2D(@"../../Content/greysquare.bmp"); currentStartSprite = new Sprite(system, greenBox); currentStartSprite.Scale = new Vector3(.5f, .5f, 1f); GetLevel(@"http://www.hacker.org/coil/index.php?name=Allosentient&password=XXXXX"); currentMoveList = new SingleUndoMoveData(); undoData = new UndoData(system, sizeY); #endregion }
public UndoData(UndoData data) { tilesize = data.tilesize; pixels = new int[tilesize, tilesize]; for (int iRow = 0; iRow < tilesize; iRow++) for (int iColumn = 0; iColumn < tilesize; iColumn++) pixels[iColumn, iRow] = data.pixels[iColumn, iRow]; }
public void PushUndo(Cell cell, Point localTileID, Brush brush) { var ud = new UndoData(cell, localTileID, brush); _undo[_index].Add(ud); }
public UndoData(UndoData data) { subpalette = data.subpalette; name = data.name; desc = data.desc; width = data.width; height = data.height; int nTiles = width * height; tiles = new Tile.UndoData[nTiles]; for (int i = 0; i < nTiles; i++) tiles[i] = new Tile.UndoData(data.tiles[i]); }