internal void addSelectedToTrack() { var objects = KKAPI.Studio.StudioAPI.GetSelectedObjects(); if (objects.Count() == 0) { show_blocking_message_time_sc("Nothing selected"); return; } else { foreach (var objectCtrl in objects) { try { SceneFolders.AddToTrack(objectCtrl); } catch { continue; } } SceneFolders.LoadTrackedActorsAndProps(); } }
public void deleteSaveData() { SceneConsole sc = SceneConsole.Instance; SetExtendedData(new PluginData() { data = null }); sc.block = new SceneManager(); SceneFolders.LoadTrackedActorsAndProps(); }
//import_or_reload("sceneutils") //import_or_reload("posesavestate") // :::::::::: JSON Derulo :::::::::::: // :::::::::: For debug only :::::::::::: // :type game:vngameengine.VNNeoController public static void start(VNNeoController game) { UI.sceneConsoleGUIStart(game); SceneFolders.LoadTrackedActorsAndProps(); // if no blocks - autoload if (SceneConsole.Instance.block.Count == 0) { if (Folder.find_single_startswith("-scenesavestate:") != null) { SceneConsole.Instance.loadSceneData(); SceneConsole.Instance.show_blocking_message_time_sc("Scene data was auto-loaded!"); } } }
internal void loadSceneData(bool backup = false, bool setToFirst = true) { string filename; SceneFolders.LoadTrackedActorsAndProps(); if (backup) { if (svname == "") { filename = defaultBackupName; } else { filename = svname + ".backup"; } } else { if (svname == "") { filename = defaultSaveName; } else { filename = svname; } } // abs_file_path = os.Path.Combine(script_dir, file_path) // if os.File.Exists(abs_file_path): // f = open(abs_file_path, "r") // block_dict = Utils.DeserializeData(f.read(), object_hook=sceneDecoder) # , indent = 4, separators = (","," : "))) // f.close() LoadFromFile(filename); // loading if (setToFirst) { if (block.HasScenes) { block.First(); block.FirstCam(); } } }
internal void delSelectedFromTrack() { var elem = NeoOCI.create_from_selected(); if (elem == null) { show_blocking_message_time_sc("Nothing selected"); return; } if (elem is VNActor.Actor chara) { var actors = game.AllActors; var id = ""; foreach (var actid in actors.Keys) { if (actors[actid].objctrl == elem.objctrl) { // found id = actid; break; } } if (id == "") { show_blocking_message_time_sc("Can't delete; seems this actor is not tracking yet"); return; } delActorFromTrack(id); } else if (elem is Prop) { var props = game.AllProps; var id = ""; foreach (var propid in props.Keys) { if (props[propid].objctrl == elem.objctrl) { id = propid; // found break; } } delPropFromTrack(id); } // updating set SceneFolders.LoadTrackedActorsAndProps(); }
internal void LoadPluginData(PluginData pluginData) { if (pluginData == null || pluginData?.data == null) { block = new SceneManager(); saveDataSize = 0; } else { byte[] sceneData = pluginData.data["scenes"] as byte[]; if (sceneData != null && sceneData.Length > 0) { try { var scenes = Utils.DeserializeData <Scene[]>(sceneData); object temp; pluginData.data.TryGetValue("currentScene", out temp); int sceneIndex = (temp as int?) ?? 0; pluginData.data.TryGetValue("sceneNames", out temp); string sceneNames = temp as string; pluginData.data.TryGetValue("trackMap", out temp); track_map = (temp as bool?) ?? true; string[] sceneStrings = SceneManager.DeserializeSceneStrings(sceneNames); block = new SceneManager(scenes, currentSceneIndex: sceneIndex, sceneStrings: sceneStrings); var saveDataSizeKb = CalculateSaveDataSize(sceneData); Logger.LogMessage($"Loaded {(saveDataSizeKb):N} Kb of scene state data."); saveDataSize = saveDataSizeKb; } catch (Exception e) { Logger.LogError("Error occurred while loading scene data: " + e.ToString()); Logger.LogMessage("Failed to load scene data, check debug log for more info."); } } } SceneFolders.LoadTrackedActorsAndProps(); loadCurrentScene(); }
public Scene(VNNeoController game, bool importSys) : this(new Dictionary <string, ActorData>(), new Dictionary <string, NEOItemData>(), new Dictionary <string, LightData>(), new Dictionary <string, NEOPropData>(), new List <CamData>()) { SceneFolders.LoadTrackedActorsAndProps(); Dictionary <string, VNActor.Actor> actors = game.AllActors; Dictionary <string, Prop> props = game.AllProps; foreach (string actid in actors.Keys) { this.actors[actid] = (ActorData)actors[actid].export_full_status(); } foreach (string propid in props.Keys) { var prop = props[propid]; AddProp(propid, prop); } if (importSys) { this.sys = (VNEngine.System.SystemData)export_full_status(); } }
internal void changeSelTrackID(string toId) { if (toId == "") { show_blocking_message_time_sc("Please, set ID to change to first"); return; } var elem = NeoOCI.create_from_selected(); if (elem == null) { show_blocking_message_time_sc("Nothing selected"); return; } if (elem is VNActor.Actor chara) { var actors = game.AllActors; string id = ""; foreach (var actid in actors.Keys) { if (actors[actid].objctrl == elem.objctrl) { // found id = actid; break; } } //self.delActorFromTrack(actid) if (id == "") { show_blocking_message_time_sc("Can't find actor to change ID"); return; } // actually changing ID changeActorTrackId(id, toId); } // updating set SceneFolders.LoadTrackedActorsAndProps(); }
// Set scene chars with state data from dictionary internal void SetSceneState(Scene s) { if (isSysTracking) { VNEngine.System.import_status(s.sys, track_map); } foreach (var actid in s.actors.Keys) { var actors = game.AllActors; foreach (var kvp in actors) { s.actors.TryGetValue(kvp.Key, out ActorData char_status); if (char_status is null) { kvp.Value.Visible = false; } else { try { char_status.Apply(kvp.Value); } catch (Exception e) { SceneConsole.Instance.game.GetLogger.LogError($"Error occurred when importing Actor with id {actid}" + e.ToString()); SceneConsole.Instance.game.GetLogger.LogMessage($"Error occurred when importing Actor with id {actid}"); SceneFolders.LoadTrackedActorsAndProps(); } } } } string propid = ""; try { foreach (var kvp in game.AllProps) { propid = kvp.Key; if (kvp.Value is Item i) { s.items.TryGetValue(kvp.Key, out var status); s.ApplyStatus(i, status); } else if (kvp.Value is VNActor.Light l) { s.lights.TryGetValue(kvp.Key, out var status); s.ApplyStatus(l, status); } else if (kvp.Value is Prop p) { s.props.TryGetValue(kvp.Key, out var status); s.ApplyStatus(p, status); } } } catch (Exception e) { game.GetLogger.LogError($"Error occurred when importing Prop with id {propid}" + e.ToString()); SceneFolders.LoadTrackedActorsAndProps(); Instance.game.GetLogger.LogMessage($"Error occurred when importing Prop with id {propid}"); } }
public static void sceneConsoleTrackable() { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(ColumnWidth)); GUILayout.Label("Actors:"); tracking_actors_scroll = GUILayout.BeginScrollView(tracking_actors_scroll); var actors = Instance.game.AllActors; foreach (var actorid in actors.Keys) { VNActor.Actor actor = actors[actorid]; render_ui_for_tracking(actorid, actor); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(ColumnWidth)); GUILayout.Label("Props:"); tracking_props_scroll = GUILayout.BeginScrollView(tracking_props_scroll); var props = Instance.game.AllProps; foreach (var propid in props.Keys) { render_ui_for_tracking(propid, props[propid]); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(ColumnWidth)); if (GUILayout.Button("Track selected", GUILayout.Height(50), GUILayout.Width(ColumnWidth))) { Instance.addSelectedToTrack(); } if (GUILayout.Button("Untrack selected", GUILayout.Height(25), GUILayout.Width(ColumnWidth))) { if (Instance.promptOnDelete.Value) { warning_action = Instance.delSelectedFromTrack; warning_param = new WarningParam_s("Untrack and delete selected from scenes?", false); } else { Instance.delSelectedFromTrack(); } } if (GUILayout.Button("Refresh", GUILayout.Height(25), GUILayout.Width(ColumnWidth))) { SceneFolders.LoadTrackedActorsAndProps(); } if (!Instance.isSysTracking) { if (GUILayout.Button("Track scene settings", GUILayout.Height(25), GUILayout.Width(ColumnWidth))) { Instance.addSysTracking(); } } else { if (GUILayout.Button("Untrack scene settings", GUILayout.Height(25), GUILayout.Width(ColumnWidth))) { Instance.delSysTracking(); } } if (Instance.track_map) { if (GUILayout.Button("Stop tracking map selection", GUILayout.Height(25), GUILayout.Width(ColumnWidth))) { Instance.track_map = false; } } else { if (GUILayout.Button("Track map selection", GUILayout.Height(25), GUILayout.Width(ColumnWidth))) { Instance.track_map = true; } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.Label("Pro: Change selected char ID to "); //GUILayout.Label(" Who say:", GUILayout.Width(80)) Instance.newid = GUILayout.TextField(Instance.newid); if (GUILayout.Button("Change", GUILayout.Width(60))) { //sc.cam_whosay = sc.get_next_speaker(sc.cam_whosay, False) Instance.changeSelTrackID(Instance.newid); } GUILayout.EndHorizontal(); }