//Construct a new DatabaseParams as a copy of a given DatabaseParams public DatabaseParams(DatabaseParams toCopy) { pixelScale = toCopy.getPixelScale(); alphaColor = toCopy.getAlphaColor(); alphaThreshold = toCopy.getAlphaThreshold(); alphaSoftness = toCopy.getAlphaThreshold(); hasAlpha = toCopy.getHasAlpha(); minPhi = toCopy.getMinPhi(); maxPhi = toCopy.getMaxPhi(); minTheta = toCopy.getMinTheta(); maxTheta = toCopy.getMaxTheta(); phiRescaled = toCopy.getPhiRescaled(); thetaRescaled = toCopy.getThetaRescaled(); invertPhi = toCopy.getInvertPhi(); invertTheta = toCopy.getInvertTheta(); phiAlignment = toCopy.getPhiAlignment(); thetaAlignment = toCopy.getThetaAlignment(); directory = toCopy.getDirectory(); online = toCopy.getOnline(); }
/** * Loads the database */ private void LoadDatabase() { panelTitle.text = databaseParams.getDirectory().Substring(databaseParams.getDirectory().LastIndexOf(Path.DirectorySeparatorChar) + 1); //Reads file into JSONObject Stream file; if (!databaseParams.getOnline()) { file = File.OpenRead(databaseParams.getDirectory() + Path.DirectorySeparatorChar + "info.json"); } else { WebClient client = new WebClient(); file = client.OpenRead(databaseParams.getDirectory() + "/" + "info.json"); } StreamReader reader = new StreamReader(file); JSONObject json_data = new JSONObject(reader.ReadToEnd()); //Load arguments into CinemaVariable objects if (json_data.HasField("arguments")) { arguments = new CinemaArgument[json_data["arguments"].Count]; } else { throw new Exception("Error reading JSON: Couldn't find field 'arguments'"); } //Read name_pattern if (json_data.HasField("name_pattern")) { name_pattern = CinemaArgument.TrimQuotes(json_data["name_pattern"].ToString()); } else { throw new Exception("Error reading JSON: Couldn't find field 'name_pattern'"); } //Iterates through arguments, initializes phi and theta if found, //Creates a varPanel for the others int skipped = 0; for (int i = 0; i < arguments.Length; i++) { arguments[i] = new CinemaArgument(json_data["arguments"][i]); if (arguments[i].GetLabel().Equals("phi")) //Argument is phi { phiVar = arguments[i]; phiValues = new float[phiVar.GetValues().Length]; for (int j = 0; j < phiValues.Length; j++) { phiValues[j] = float.Parse(phiVar.GetValues()[j]); } skipped++; } else if (arguments[i].GetLabel().Equals("theta")) //Argument is theta { thetaVar = arguments[i]; thetaValues = new float[thetaVar.GetValues().Length]; for (int j = 0; j < thetaValues.Length; j++) { thetaValues[j] = float.Parse(thetaVar.GetValues()[j]); } skipped++; } else //Argument is neither phi nor theta { if (arguments[i].GetValues().Length > 1) { //Instantiates a varPanel for this argument GameObject varPanel = Instantiate <GameObject>(argPanelPrefab); varPanel.transform.SetParent(controlPanel.transform, false); varPanel.transform.Translate(0, -0.5f - (0.7f * (i - skipped)), 0); panelFooter.transform.Translate(0, -0.7f, 0); argPanelControls controls = varPanel.GetComponent <argPanelControls>(); controls.Init(this); controls.SetCinemaVariable(arguments[i]); } else //Argument is skipped if there is only one value for it { skipped++; } } } //Set up background alpha material if this database has alpha if (databaseParams.getHasAlpha()) { Material mat = new Material(alphaShader); mat.SetColor("_AlphaColor", databaseParams.getAlphaColor()); mat.SetFloat("_AlphaThreshold", databaseParams.getAlphaThreshold()); mat.SetFloat("_AlphaSoftness", databaseParams.getAlphaSoftness()); GetComponent <SpriteRenderer>().material = mat; } } //end LoadDatabase()