private void drawPatients() { if (!m_hasTriggers) { return; } Bitmap timeBlock = Resources.blockTime; Bitmap balloon = Resources.balloon_normal; float scale = 0.8f; int balloonWidth = (int)(balloon.Width * scale); int balloonHeight = (int)(balloon.Height * scale); Rectangle balloonSpace = new Rectangle((int)(27 * scale), (int)(4 * scale), (int)(116 * scale), (int)(116 * scale)); int iconWidth = (int)(96 * scale); int iconHeight = (int)(96 * scale); int iconOffsetX = balloonSpace.X + (balloonSpace.Width / 2) - (iconWidth / 2); int iconOffsetY = balloonSpace.Y + (balloonSpace.Height / 2) - (iconHeight / 2); int x = 0; int y = 0; Bitmap dest = new Bitmap(12 * balloonWidth, m_Patients.Count * balloonHeight, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(dest); Random rnd = new Random(); for (int p = 0; p < m_Patients.Count; p++) { Patient patient = m_Patients[p]; // delay block g.DrawImage(timeBlock, x, y, balloonHeight, balloonHeight); StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; g.DrawString(patient.delay.ToString(), new Font(FontFamily.GenericSansSerif, 18 * scale, FontStyle.Bold), Brushes.White, new Rectangle(x, y, balloonHeight, balloonHeight), sf); x += balloonHeight; // patient avatar int id = rnd.Next(0, m_PatientTypes.Count); Bitmap img = m_PatientTypes[id].image; g.DrawImage(img, x, y, balloonHeight, balloonHeight); x += balloonHeight; for (int s = 0; s < patient.stepNames.Count; s++) { string name = patient.stepNames[s]; TreatmentStep step = getTreatmentStep(patient.stepNames[s]); balloon = (step.type == "product") ? Resources.balloon_product : (step.type == "minigame") ? Resources.balloon_minigame : (step.type == "gesture") ? Resources.balloon_minigame : Resources.balloon_normal; g.DrawImage(balloon, x, y, balloonWidth, balloonHeight); g.DrawImage(step.icon, x + iconOffsetX, y + iconOffsetY, iconWidth, iconHeight); x += balloonWidth; } x = 0; y += balloonHeight; } pictureBox1.Width = dest.Width; pictureBox1.Height = dest.Height; pictureBox1.Image = dest; }
private void getTreatmentsFromRoomFile(string roomName) { string absPath = m_DataFolderPath + @"script\rooms\defaults\" + @roomName + @"_game.lua"; if (!File.Exists(absPath)) { return; } string rawText = File.ReadAllText(@absPath); rawText = rawText.Replace("\r\n", ""); rawText = rawText.Replace("\r", ""); rawText = rawText.Replace("\n", ""); rawText = rawText.Replace("\t", ""); rawText = rawText.Replace(" ", ""); string treatmentsTableText = getTableText(rawText, "treatments"); for (int p = 0; p < m_Patients.Count; p++) { Patient patient = m_Patients[p]; for (int t = 0; t < patient.stepNames.Count; t++) { TreatmentStep step = new TreatmentStep(); string treatmentName = patient.stepNames[t]; if (treatmentName == "") { continue; } if (!doesTreatmentExists(treatmentName)) { string tableText = getTableText(treatmentsTableText, treatmentName); step.name = treatmentName; string workIconName = getVariable(tableText, "workIcon"); string productName = getVariable(tableText, "product"); string fileName = workIconName != "" ? workIconName : getProductName(productName); if (getVariable(tableText, "choices") != "") { fileName += "_1"; } string iconPath = m_DataFolderPath + @"images\rooms\" + @roomName + @"\icons\" + fileName + ".png"; if (File.Exists(iconPath)) { step.icon = new Bitmap(iconPath); } else { fileName = getProductName(productName); iconPath = m_DataFolderPath + @"images\rooms\" + @roomName + @"\icons\" + fileName + ".png"; if (File.Exists(iconPath)) { step.icon = new Bitmap(iconPath); } else { step.icon = Resources.noicon; } } step.type = productName != "" ? "product" : getVariable(tableText, "minigame") != "" ? "minigame" : getVariable(tableText, "gesture") != "" ? "gesture" : "normal"; m_Treatments.Add(step); } } } }