#include #include #include #include // Item costs, growing times, selling prices, and so on. // Spring crops. // Count down towards 0 each time the user ends the day. When the user calls Harvest(), check for crops that have 0 in their .Time and add the value of .Regrow to .Time. Next, check if .Time is 0. If it is, remove the crop since it can only be harvested once. // At the end of a month, wipe the crops. Obviously. //Remember Wednsday! // Add SpeedGro adjusters at some point. // Figure out how to handle multi-harvest crops for Artisan goods. For now we'll entirely ignore this and just figure out what time it's best to grow which crops and be happy with that, but at some point we'll need to figure out how to handle Potatoes. Blueberries and Cranberries are easy, but Potatoes is weird since it's at 1.25. owo. // Fopen, fclose.. Need to log what ypu dfp EVERY day in case the run's really good! OwO! Check current directory/StardewSimulatorLogs, just name then 1.txt, 2.txt and so on. owo. // Consider adding one hour per 100 crops harvested. That's been a problem before at some points for me. //++ Make it so that the extra space at the bottom of the Crops panel shows like "Crops planted: 0/1,765". // Line 1017, read around there! Ucj, gotta do so much. 0) { CropPlot[i].DateRemaining += Crop[CropPlot[i].ID].Regrow; CropPlot[i].DateHarvest += Crop[CropPlot[i].ID].Regrow; } else { CropPlot[i].ID = 0; CropPlot[i].Quantity = 0; CropPlot[i].DateSeeded = 0; CropPlot[i].DateHarvest = 0; } UpdateWindowFarm(); UpdateWindowStats(); } } } return 0; } int BuyItem() { //ShopSelection //ShopQuantity //CurrentMonth int i; // Crop selection counter. int j; // Slot-occupationifier-chekcifier-countifier-variabifiliacifir-thing. owo. int k = 1; // Because I can't remember how to write a "Negative If" statement. = Cost) { strncpy(ItemSlot[12].Text, Crop[i].InventoryTextSeeds, 21); ItemSlot[12].ID = Crop[i].ID; // Yeah, I know, I can just copy "i" here instead of having a reference to the ID in the Array. I'd rather not rely on the list being in perfect order, just in case, so I'm doing it this way. Besides, it makes it easier since Empty isn't 0 and Cauliflower is. owo. ItemSlot[12].Quantity = ShopQuantity; //Item is now in the "Overflow" slot. //Now we need to check if another item has the same name. for(j=0; j<12 && k == 1; j++) { if(ItemSlot[j].ID == ItemSlot[12].ID) { k = 0; } } //k = strcmp(ItemSlot[j].Text, ItemSlot[12].Text); if(k == 0) { k = 1; j--; ItemSlot[j].Quantity = ItemSlot[j].Quantity + ShopQuantity; } else { strcpy(ItemSlot[11].Text, ItemSlot[12].Text); ItemSlot[11].Quantity = ItemSlot[12].Quantity; ItemSlot[11].ID = ItemSlot[12].ID; } CurrentGold = CurrentGold - Cost; StackInventoryItems(); UpdateWindowInventory(); DrawStaticElements(3); UpdateWindowStats(); } else { // 'You don't have enough money!' here. } } else { // 'Full inventory!' here. } return 0; } int SellItem() { //InventorySelection //ItemSlot[0].Quantity int k; k = Crop[ItemSlot[InventorySelection-1].ID].Seeds * ItemSlot[InventorySelection-1].Quantity; CurrentGold = CurrentGold + k; ItemSlot[InventorySelection-1].ID = -1; ItemSlot[InventorySelection-1].Quantity = 0; ItemSlot[InventorySelection-1].Text[0] = '\0'; StackInventoryItems(); UpdateWindowStats(); UpdateWindowInventory(); return 0; } int PlantSeeds() { //InventorySelection //WorkingCropPlot int i; /* Okay, the process is going to be *something*, man. o_o... So, here's my issue: Unlike the inventory, I don't want these plots to "move" and autostack. This creates some very obvious management problems! ...Oh, duh. We can just For i=0 over them all and poke the first empty one. Derp. Selecting one would be nice, but we'll add that /later/. Functionality first. 9) { mvwprintw(WindowStats, 1, 7, "%i", CurrentDate); } else { mvwprintw(WindowStats, 1, 7, " %i", CurrentDate); } // Day-of-the-Week update. if(CurrentDayName == 1) { mvwprintw(WindowStats, 2, 7, "(1) Sunday "); } else if(CurrentDayName == 2) { mvwprintw(WindowStats, 2, 7, "(2) Monday "); } else if(CurrentDayName == 3) { mvwprintw(WindowStats, 2, 7, "(3) Tuesday "); } else if(CurrentDayName == 4) { mvwprintw(WindowStats, 2, 7, "(4) Wednesday"); } else if(CurrentDayName == 5) { mvwprintw(WindowStats, 2, 7, "(5) Thursday "); } else if(CurrentDayName == 6) { mvwprintw(WindowStats, 2, 7, "(6) Friday "); } else if(CurrentDayName == 7) { mvwprintw(WindowStats, 2, 7, "(7) Saturday "); } // Season update. if(CurrentMonth == 1) { mvwprintw(WindowStats, 2, 30, "(1) Spring"); } else if(CurrentMonth == 2) { mvwprintw(WindowStats, 2, 30, "(2) Summer"); } else if(CurrentMonth == 3) { mvwprintw(WindowStats, 2, 30, "(3) Autumn"); } else if(CurrentMonth == 4) { mvwprintw(WindowStats, 2, 30, "(4) Winter"); } // Gold update. if(CurrentGold < 10) { mvwprintw(WindowStats, 1, 30, "........%iG", CurrentGold); } else if(CurrentGold < 100) { mvwprintw(WindowStats, 1, 30, ".......%iG", CurrentGold); } else if(CurrentGold < 1000) { mvwprintw(WindowStats, 1, 30, "......%iG", CurrentGold); } else if(CurrentGold < 10000) { mvwprintw(WindowStats, 1, 30, ".....%iG", CurrentGold); } else if(CurrentGold < 100000) { mvwprintw(WindowStats, 1, 30, "....%iG", CurrentGold); } else if(CurrentGold < 1000000) { mvwprintw(WindowStats, 1, 30, "...%iG", CurrentGold); } else if(CurrentGold < 10000000) { mvwprintw(WindowStats, 1, 30, "..%iG", CurrentGold); } else if(CurrentGold < 100000000) { mvwprintw(WindowStats, 1, 30, ".%iG", CurrentGold); } else if(CurrentGold < 1000000000) { mvwprintw(WindowStats, 1, 30, "%iG", CurrentGold); } else if(CurrentGold >= 1000000000) { mvwprintw(WindowStats, 1, 30, ".You win.G", CurrentGold); } wrefresh(WindowStats); return 0; } int UpdateWindowQuickref(int a) { if(a == 0) { mvwprintw(WindowQuickref, 1, 1, " (W)ater All (H)arvest All (N)ext Day (Tab/`) Select "); mvwprintw(WindowQuickref, 2, 1, " F1-F5/Arrows move, Enter selects, Esc cancels (R)ain "); wrefresh(WindowQuickref); } else if(a == 1) { mvwprintw(WindowQuickref, 1, 1, " (E)dit mode (Enter) Return to panel selection "); mvwprintw(WindowQuickref, 2, 1, " "); wrefresh(WindowQuickref); } else if(a == 2) { mvwprintw(WindowQuickref, 1, 1, " Move the cursor with the arrow keys. Edit any (number) "); mvwprintw(WindowQuickref, 2, 1, " (Tab) cycles between editable values. (Enter) saves. "); wrefresh(WindowQuickref); } else if(a == 3) { mvwprintw(WindowQuickref, 1, 1, " Arrows select/quantity (B)uy Buy (A)ll "); mvwprintw(WindowQuickref, 2, 1, " (Enter) when done Sell/Time/Regrow/LastDay/eXpiration "); wrefresh(WindowQuickref); } return 0; } int ChangeShopInventory() { werase(WindowShop); DrawStaticElements(4); if(CurrentMonth == 1) { mvwprintw(WindowShop, 1, 5, Crop[Cauliflower].ShopText); mvwprintw(WindowShop, 2, 5, Crop[Garlic].ShopText); mvwprintw(WindowShop, 3, 5, Crop[GreenBean].ShopText); mvwprintw(WindowShop, 4, 5, Crop[Kale].ShopText); mvwprintw(WindowShop, 5, 5, Crop[Parsnip].ShopText); mvwprintw(WindowShop, 6, 5, Crop[Potato].ShopText); mvwprintw(WindowShop, 7, 5, Crop[Rhubarb].ShopText); mvwprintw(WindowShop, 8, 5, Crop[Strawberry].ShopText); mvwprintw(WindowShop, 9, 5, Crop[BlueJazz].ShopText); mvwprintw(WindowShop, 10, 5, Crop[Tulip].ShopText); mvwprintw(WindowShop, 11, 5, Crop[Empty].ShopText); mvwprintw(WindowShop, 12, 5, Crop[Empty].ShopText); mvwprintw(WindowShop, 13, 5, Crop[SweetGemBerry].ShopText); mvwprintw(WindowShop, 14, 5, Crop[AncientFruit].ShopText); } // Jake helped here. With 'w's. :3 else if(CurrentMonth == 2) { mvwprintw(WindowShop, 1, 5, Crop[Blueberry].ShopText); mvwprintw(WindowShop, 2, 5, Crop[Corn].ShopText); mvwprintw(WindowShop, 3, 5, Crop[Hops].ShopText); mvwprintw(WindowShop, 4, 5, Crop[HotPepper].ShopText); mvwprintw(WindowShop, 5, 5, Crop[Melon].ShopText); mvwprintw(WindowShop, 6, 5, Crop[Radish].ShopText); mvwprintw(WindowShop, 7, 5, Crop[RedCabbage].ShopText); mvwprintw(WindowShop, 8, 5, Crop[Starfruit].ShopText); mvwprintw(WindowShop, 9, 5, Crop[Tomato].ShopText); mvwprintw(WindowShop, 10, 5, Crop[Wheat].ShopText); mvwprintw(WindowShop, 11, 5, Crop[Poppy].ShopText); mvwprintw(WindowShop, 12, 5, Crop[SummerSpangle].ShopText); mvwprintw(WindowShop, 13, 5, Crop[SweetGemBerry].ShopText); mvwprintw(WindowShop, 14, 5, Crop[AncientFruit].ShopText); } else if(CurrentMonth == 3) { mvwprintw(WindowShop, 1, 5, Crop[Amaranth].ShopText); mvwprintw(WindowShop, 2, 5, Crop[Artichoke].ShopText); mvwprintw(WindowShop, 3, 5, Crop[Beet].ShopText); mvwprintw(WindowShop, 4, 5, Crop[BokChoy].ShopText); mvwprintw(WindowShop, 5, 5, Crop[Cranberries].ShopText); mvwprintw(WindowShop, 6, 5, Crop[Eggplant].ShopText); mvwprintw(WindowShop, 7, 5, Crop[Grape].ShopText); mvwprintw(WindowShop, 8, 5, Crop[Pumpkin].ShopText); mvwprintw(WindowShop, 9, 5, Crop[Yam].ShopText); mvwprintw(WindowShop, 10, 5, Crop[FairyRose].ShopText); mvwprintw(WindowShop, 11, 5, Crop[Sunflower].ShopText); mvwprintw(WindowShop, 12, 5, Crop[Empty].ShopText); mvwprintw(WindowShop, 13, 5, Crop[SweetGemBerry].ShopText); mvwprintw(WindowShop, 14, 5, Crop[AncientFruit].ShopText); } return 0; } int UpdateWindowShop() { ChangeShopInventory(); wrefresh(WindowShop); return 0; } int UpdateWindowInventory() { int i; for(i=0; i<12; i++) { // This was at i<13 before. Commenting in case weird stuff happens. CHECKHEREGAIN OWO wmove(WindowInventory, i+1, 6); wclrtoeol(WindowInventory); DrawStaticElements(2); mvwprintw(WindowInventory, i+1, 6, "%s", ItemSlot[i].Text); mvwaddch(WindowInventory, i+1, getmaxx(WindowInventory)-9, ACS_VLINE); mvwprintw(WindowInventory, i+1, getmaxx(WindowInventory)-8, "(%i)", ItemSlot[i].Quantity); wrefresh(WindowInventory); } return 0; } int UpdateWindowFarm() { int i; for(i=0; i<12; i++) { mvwprintw(WindowCrop[i], 1, 7, "%s (%i)", Crop[CropPlot[i].ID].InventoryTextCrop, CropPlot[i].Quantity); mvwprintw(WindowCrop[i], 2, 9, "%.2i", CropPlot[i].DateSeeded); mvwprintw(WindowCrop[i], 2, 21, "%.2i", CropPlot[i].DateHarvest); mvwprintw(WindowCrop[i], 2, 30, "%.2i", CropPlot[i].DateRemaining); if(CropPlot[i].Watered == 0) { mvwprintw(WindowCrop[i], 2, 33, "DRY"); } else if(CropPlot[i].Watered == 1) { mvwprintw(WindowCrop[i], 2, 33, "WET"); } // Clear empty plots. if(CropPlot[i].ID == 0) { mvwprintw(WindowCrop[i], 1, 7, " "); mvwprintw(WindowCrop[i], 2, 9, " "); mvwprintw(WindowCrop[i], 2, 21, " "); mvwprintw(WindowCrop[i], 2, 30, " "); } wrefresh(WindowCrop[i]); } return 0; } int DoGlobalAction(char Action) { int i; if(Action == 'n' || Action == 'N') { // Date advancement. CurrentDate++; if(CurrentDate > 28) { CurrentDate = 1; CurrentMonth++; if(CurrentMonth > 4) { CurrentMonth = 1; } } CurrentDayName++; if(CurrentDayName > 7) { CurrentDayName = 1; }; GrowCrops(); for(i=0; i<12; i++) { CropPlot[i].Watered = 0; if(Crop[CropPlot[i].ID].Season != CurrentMonth) { RemoveCrop(i); } } UpdateWindowStats(); UpdateWindowShop(); UpdateWindowFarm(); //GrowCrops(); } if(Action == 'w' || Action == 'W') { for(i=0; i<12; i++) { CropPlot[i].Watered = 1; } UpdateWindowFarm(); } if(Action == 'h' || Action == 'H') { DoHarvest(); } return 0; } int InteractWindowStats() { int PanelOneSelection = 1; int PanelOneEditing = 0; int KeyPressed; int ScanDate; int ScanStam; char ScanGold[102]; char ScanGoldConversion[102]; char ScanBuffer[102]; int ScanDay; int ScanSeason; int i; int j = 0; keypad(WindowStats, TRUE); KeyPressed = 0; while(KeyPressed != '\r' && KeyPressed != '\n' && KeyPressed != KEY_ENTER) { wrefresh(WindowStats); UpdateWindowQuickref(1); KeyPressed = getch(); if(KeyPressed == 'n' || KeyPressed == 'N') { DoGlobalAction('n'); } if(KeyPressed == 'w' || KeyPressed == 'W') { DoGlobalAction('w'); } if(KeyPressed == 'h' || KeyPressed == 'H') { DoGlobalAction('h'); } if(KeyPressed == 'E' || KeyPressed == 'e') { curs_set(2); UpdateWindowQuickref(2); PanelOneEditing = 1; // Get last input location. if(PanelOneSelection == 1) { wmove(WindowStats, 1, 8); } else if(PanelOneSelection == 2) { wmove(WindowStats, 1, 18); } else if(PanelOneSelection == 3) { wmove(WindowStats, 1, 30); } else if(PanelOneSelection == 4) { wmove(WindowStats, 2, 8); } else if(PanelOneSelection == 5) { wmove(WindowStats, 2, 31); } while(PanelOneEditing == 1) { wrefresh(WindowStats); refresh(); // Actual editing happens here! KeyPressed = wgetch(WindowStats); // Jump to specific cells (See code above too!). if(KeyPressed == '\t') { PanelOneSelection++; if(PanelOneSelection > 5) { PanelOneSelection = 1; } if(PanelOneSelection == 1) { wmove(WindowStats, 1, 8); } else if(PanelOneSelection == 2) { wmove(WindowStats, 1, 18); } else if(PanelOneSelection == 3) { wmove(WindowStats, 1, 30); } else if(PanelOneSelection == 4) { wmove(WindowStats, 2, 8); } else if(PanelOneSelection == 5) { wmove(WindowStats, 2, 31); } } else // Move to another cell using the arrow keys. if(KeyPressed == KEY_LEFT) { wmove(WindowStats, getcury(WindowStats), getcurx(WindowStats)-1); } else if(KeyPressed == KEY_RIGHT) { wmove(WindowStats, getcury(WindowStats), getcurx(WindowStats)+1); } else if(KeyPressed == KEY_UP) { wmove(WindowStats, getcury(WindowStats)-1, getcurx(WindowStats)); } else if(KeyPressed == KEY_DOWN) { wmove(WindowStats, getcury(WindowStats)+1, getcurx(WindowStats)); } else if(KeyPressed == '0') { waddch(WindowStats, '0'); } else if(KeyPressed == '1') { waddch(WindowStats, '1'); } else if(KeyPressed == '2') { waddch(WindowStats, '2'); } else if(KeyPressed == '3') { waddch(WindowStats, '3'); } else if(KeyPressed == '4') { waddch(WindowStats, '4'); } else if(KeyPressed == '5') { waddch(WindowStats, '5'); } else if(KeyPressed == '6') { waddch(WindowStats, '6'); } else if(KeyPressed == '7') { waddch(WindowStats, '7'); } else if(KeyPressed == '8') { waddch(WindowStats, '8'); } else if(KeyPressed == '9') { waddch(WindowStats, '9'); } else if(KeyPressed == ' ') { waddch(WindowStats, ' '); } if(KeyPressed == '(') { waddch(WindowStats, '('); } if(KeyPressed == ')') { waddch(WindowStats, ')'); } if(KeyPressed == 'g' || KeyPressed == 'G') { waddch(WindowStats, 'G'); } if(KeyPressed == KEY_BACKSPACE || KeyPressed == KEY_DC || KeyPressed == '\b') { mvwaddch(WindowStats, getcury(WindowStats), getcurx(WindowStats)-1, ' '); } if(KeyPressed == '\r' || KeyPressed == '\n' || KeyPressed == KEY_ENTER) { PanelOneEditing = 0; curs_set(FALSE); } } // Now we process the user's edits! mvwinnstr(WindowStats, 1, 1, ScanBuffer, 100); sscanf(ScanBuffer, "%s %i %s %i %s %s", ScanGold, &ScanDate, ScanGold, &ScanStam, ScanGold, ScanGold); if(ScanDate < 29) { CurrentDate = ScanDate; } //Parsing the gold may be tricky. for(i = 0; i < 102; i++) { if(ScanGold[i] == '0' || ScanGold[i] == '1' || ScanGold[i] == '2' || ScanGold[i] == '3' || ScanGold[i] == '4' || ScanGold[i] == '5' || ScanGold[i] == '6' || ScanGold[i] == '7' || ScanGold[i] == '8' || ScanGold[i] == '9') { ScanGoldConversion[j] = ScanGold[i]; j++; } else if(ScanGold[i] == 'G') { ScanGoldConversion[j] = '\0'; j = 0; break; } } if(atoi(ScanGoldConversion) < 1000000000 && ScanGoldConversion[0] != '\0') { CurrentGold = atoi(ScanGoldConversion); } // Second line of the user's edits. mvwinnstr(WindowStats, 2, 1, ScanBuffer, 100); sscanf(ScanBuffer, "%s (%i) %s %s (%i) %s", ScanGold, &ScanDay, ScanGold, ScanGold, &ScanSeason, ScanGold); if(ScanDay < 8) { CurrentDayName = ScanDay; } if(ScanSeason < 5) { CurrentMonth = ScanSeason; } UpdateWindowStats(); UpdateWindowShop(); // In case the season changes. owo. KeyPressed = 0; } } return 0; } int InteractWindowQuickref() { return 0; } int InteractWindowInventory() { int InteractingInventory = 1; int i; keypad(WindowInventory, TRUE); while(InteractingInventory == 1) { UpdateWindowInventory(); mvwchgat(WindowInventory, InventorySelection, 6, 27, A_REVERSE, 0, NULL); mvwchgat(WindowInventory, InventorySelection, getmaxx(WindowInventory)-8, 7, A_REVERSE, 0, NULL); KeyPressed = wgetch(WindowInventory); if(KeyPressed == 'n' || KeyPressed == 'N') { DoGlobalAction('n'); } if(KeyPressed == 'w' || KeyPressed == 'W') { DoGlobalAction('w'); } if(KeyPressed == 'h' || KeyPressed == 'H') { DoGlobalAction('h'); } else if(KeyPressed == KEY_DOWN) { if(InventorySelection < 12) { mvwchgat(WindowInventory, InventorySelection, 6, 27, A_NORMAL, 0, NULL); mvwchgat(WindowInventory, InventorySelection, getmaxx(WindowInventory)-8, 7, A_NORMAL, 0, NULL); InventorySelection++; } } else if(KeyPressed == KEY_UP) { if(InventorySelection > 1) { mvwchgat(WindowInventory, InventorySelection, 6, 27, A_NORMAL, 0, NULL); mvwchgat(WindowInventory, InventorySelection, getmaxx(WindowInventory)-8, 7, A_NORMAL, 0, NULL); InventorySelection--; } } /*else if(KeyPressed == KEY_RIGHT) { if(ShopQuantitySelect < 7) { ShopQuantitySelect++; } } else if(KeyPressed == KEY_LEFT) { if(ShopQuantitySelect > 1) { ShopQuantitySelect--; } } -- Considering using this for buying and selling, maybe.. Somehow. -w-. */ else if(KeyPressed == 'S' || KeyPressed == 's') { SellItem(); } else if(KeyPressed == 'P' || KeyPressed == 'p') { PlantSeeds(); } else if(KeyPressed == '\r' || KeyPressed == '\n' || KeyPressed == KEY_ENTER) { InteractingInventory = 0; mvwchgat(WindowInventory, InventorySelection, 6, 27, A_NORMAL, 0, NULL); mvwchgat(WindowInventory, InventorySelection, getmaxx(WindowInventory)-8, 7, A_NORMAL, 0, NULL); UpdateWindowInventory(); } } return 0; } int InteractWindowShop() { keypad(WindowShop, TRUE); int Shopping = 1; UpdateWindowQuickref(3); if(ShopQuantitySelect == 0) { ShopQuantitySelect = 1; } while(Shopping == 1) { mvwchgat(WindowShop, ShopSelection, 5, getmaxx(WindowShop)-7, A_REVERSE, 0, NULL); mvwchgat(WindowShop, 15, 1, getmaxx(WindowShop)-2, A_NORMAL, 0, NULL); if(ShopQuantitySelect == 1) { mvwchgat(WindowShop, 15, 1, 5, A_REVERSE, 0, NULL); ShopQuantity = 1; } else if(ShopQuantitySelect == 2) { mvwchgat(WindowShop, 15, 9, 5, A_REVERSE, 0, NULL); ShopQuantity = 5; } /*else if(ShopQuantitySelect == 2) { mvwchgat(WindowShop, 15, 9, 5, A_REVERSE, 0, NULL); ShopQuantity = 9; }*/ else if(ShopQuantitySelect == 3) { mvwchgat(WindowShop, 15, 17, 5, A_REVERSE, 0, NULL); ShopQuantity = 9; } else if(ShopQuantitySelect == 4) { mvwchgat(WindowShop, 15, 25, 6, A_REVERSE, 0, NULL); ShopQuantity = 10; } else if(ShopQuantitySelect == 5) { mvwchgat(WindowShop, 15, 34, 6, A_REVERSE, 0, NULL); ShopQuantity = 25; } else if(ShopQuantitySelect == 6) { mvwchgat(WindowShop, 15, 43, 6, A_REVERSE, 0, NULL); ShopQuantity = 36; } else if(ShopQuantitySelect == 7) { mvwchgat(WindowShop, 15, 50, 7, A_REVERSE, 0, NULL); ShopQuantity = 100; } wrefresh(WindowShop); wrefresh(WindowInventory); KeyPressed = wgetch(WindowShop); if(KeyPressed == 'n' || KeyPressed == 'N') { DoGlobalAction('n'); } if(KeyPressed == 'w' || KeyPressed == 'W') { DoGlobalAction('w'); } if(KeyPressed == 'h' || KeyPressed == 'H') { DoGlobalAction('h'); } else if(KeyPressed == KEY_DOWN) { if(ShopSelection < 14) { mvwchgat(WindowShop, ShopSelection, 5, getmaxx(WindowShop)-7, A_NORMAL, 0, NULL); ShopSelection++; } } else if(KeyPressed == KEY_UP) { if(ShopSelection > 1) { mvwchgat(WindowShop, ShopSelection, 5, getmaxx(WindowShop)-7, A_NORMAL, 0, NULL); ShopSelection--; } } else if(KeyPressed == KEY_RIGHT) { if(ShopQuantitySelect < 7) { ShopQuantitySelect++; } } else if(KeyPressed == KEY_LEFT) { if(ShopQuantitySelect > 1) { ShopQuantitySelect--; } } else if(KeyPressed == 'B' || KeyPressed == 'b') { BuyItem(); } else if(KeyPressed == 'A' || KeyPressed == 'a') { // BuyAll(); } else if(KeyPressed == '\r' || KeyPressed == '\n' || KeyPressed == KEY_ENTER) { Shopping = 0; mvwchgat(WindowShop, ShopSelection, 5, getmaxx(WindowShop)-7, A_NORMAL, 0, NULL); mvwchgat(WindowShop, 15, 1, getmaxx(WindowShop)-2, A_NORMAL, 0, NULL); wrefresh(WindowShop); } } return 0; } int InteractWindowFarm() { int i; keypad(WindowFarm, TRUE); int Farming = 1; //DrawStaticElements(5); //FarmSelection while(Farming == 1) { for(i=0; i<12; i++) { wborder(WindowCrop[i], ACS_VLINE | A_NORMAL, ACS_VLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_ULCORNER | A_NORMAL, ACS_URCORNER | A_NORMAL, ACS_LLCORNER | A_NORMAL, ACS_LRCORNER | A_NORMAL); wrefresh(WindowCrop[i]); } wborder(WindowCrop[FarmSelection], ACS_VLINE | A_BOLD, ACS_VLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_ULCORNER | A_BOLD, ACS_URCORNER | A_BOLD, ACS_LLCORNER | A_BOLD, ACS_LRCORNER | A_BOLD); wrefresh(WindowCrop[FarmSelection]); KeyPressed = wgetch(WindowFarm); if(KeyPressed == 'n' || KeyPressed == 'N') { DoGlobalAction('n'); } if(KeyPressed == 'w' || KeyPressed == 'W') { DoGlobalAction('w'); } if(KeyPressed == 'h' || KeyPressed == 'H') { DoGlobalAction('h'); } else if(KeyPressed == KEY_DOWN) { if(FarmSelection < 11) { FarmSelection++; // Code above'll handle actually updating the windows! I hope! Whee! OwO! } } else if(KeyPressed == KEY_UP) { if(FarmSelection > 0) { FarmSelection--; } } else if(KeyPressed == KEY_RIGHT) { if(FarmSelection < 6) { FarmSelection+=6; } } else if(KeyPressed == KEY_LEFT) { if(FarmSelection > 5) { FarmSelection-=6; } } else if(KeyPressed == '\r' || KeyPressed == '\n' || KeyPressed == KEY_ENTER) { Farming = 0; } } // When done, clear the highlighted one. for(i=0; i<12; i++) { wborder(WindowCrop[i], ACS_VLINE | A_NORMAL, ACS_VLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_ULCORNER | A_NORMAL, ACS_URCORNER | A_NORMAL, ACS_LLCORNER | A_NORMAL, ACS_LRCORNER | A_NORMAL); wrefresh(WindowCrop[i]); } return 0; } int DoEvents() { return 0; } int main(void) { initscr(); // Here we go! resize_term(50, 100); raw(); noecho(); keypad(stdscr, TRUE); curs_set(FALSE); MakeCropStructs(); MakeCropPlotStructs(); CreateWindowsInMemory(); DrawStaticElements(0); InitalizeNewGame(); UpdateWindowStats(); UpdateWindowShop(); SwitchActiveWindow(); // Calling so it's obvious that there's /a/ selection. while(1) { UpdateWindowQuickref(0); keypad(stdscr, TRUE); // Always re-get arrow and F-keys from any other windows that take it. DrawStaticElements(3); KeyPressed = getch(); if(KeyPressed == 'n' || KeyPressed == 'N') { DoGlobalAction('n'); } if(KeyPressed == 'w' || KeyPressed == 'W') { DoGlobalAction('w'); } if(KeyPressed == 'h' || KeyPressed == 'H') { DoGlobalAction('h'); } if(KeyPressed == KEY_STAB || KeyPressed == KEY_BTAB || KeyPressed == '\t' || KeyPressed == '`' || KeyPressed == '~') { // Active Window switching. if(KeyPressed == '`' || KeyPressed == '~') { ActiveWindow--; if(ActiveWindow == 0) { ActiveWindow = 5; } } else { ActiveWindow++; if(ActiveWindow > 5) { ActiveWindow = 1; } } SwitchActiveWindow(); } else if(KeyPressed == '\r' || KeyPressed == '\n' || KeyPressed == KEY_ENTER) { if(ActiveWindow == 1) { InteractWindowStats(); } else if(ActiveWindow == 2) { InteractWindowQuickref(); } else if(ActiveWindow == 3) { InteractWindowInventory(); } else if(ActiveWindow == 4) { InteractWindowShop(); } else if(ActiveWindow == 5) { InteractWindowFarm(); } } DoEvents(); } endwin(); return 0; }