Commit Graph

123 Commits (master)

Author SHA1 Message Date
kts 49ce932ece data.c/.h added to devcpp project. Tile editor runs fine on win32/64. 2014-01-21 00:15:02 -08:00
kts 48574819b8 I have Done The Right Thing(tm) and made the tab key jump to the next Spinner or TextInput element it can find in the Element chain. 2014-01-20 17:00:40 -08:00
kts 2e48e2e1fa The tile editor's Data struct(tiles_data) isa) and accompanying sets(up to 7 default) are now created on start. This allows for the saving of Data without a file needed to be loaded prior. Some code should be moved to data.c/.h and the entire thing needs to be stress tested. 2014-01-20 06:46:32 -08:00
kts 75b1960fe1 Table's count property was not initialized to 0 in newTable, thus causing erroneous behavior on OS X - now initialized properly. 2014-01-20 02:44:59 -08:00
kts 149cd25ef9 After much struggling due to a fool's lack of documentation, the tile_editor is now (seemingly) fully functional. Changes to tile entries can now be made by adding/deleting/modifying the UI elements and pressing the 'commit changes' button. This only does a change for the TileData, etc., stored in ram. These changes can be saved to a file by specifying a filename in the data field and pressing the 'save' button. On a more technical note, fixed some bugs in the data reading code, such as inventory lines being partially read but then being assigned as a simple key=>string pair rather than an InventoryData struct - this, of course, caused segfaults and was particularly mystifying. Table structs now also have a 'count' property that is incremented or decremented whenever a TablePair is added. 2014-01-20 02:21:15 -08:00
kts 9fe34501b5 Added a commit changes button that will save the key=>value Elements to TileData/TablePair/InventoryData, etc. structs. At the moment it only parses the elements and printf()s the key=>value pairs, including inventory elements. 2014-01-19 20:56:13 -08:00
kts 8615026e0b Fixed a minor bug wherein the editor_elements ElementList's last property was not set to the Inventory Item Element of a new Inventory declaration. 2014-01-19 18:02:54 -08:00
kts a81419d662 Adding and deleting of Pair(s) and Inventory(s), as well as adding and deleting of Inventory Items now fully works. Some of the code is messy, but it works fine. Next on the itinerary is the saving of changed Elements to TileData/TablePair(s), then the saving of all such changed data back to a tsd file\! 2014-01-19 17:43:36 -08:00
kts ff8409be64 Added UI elements for InventoryData in the tile editor. Also added various buttons for deleting key=>value pairs and for adding new pairs, new inventories, and new inventory items. These buttons do not change anything at the moment. Also changed the tile editor's dimensions. 2014-01-19 02:29:01 -08:00
kts 38f62c970e Spinner and TextInput Elements now change cursor position based on mouseup coordinates. 2014-01-18 03:52:31 -08:00
kts 4ea6159ef6 Added data.c/.h to xcode project for both the engine and the editor and tested both on OS X. 2014-01-17 04:34:43 -08:00
kts 30f71466fd Much progress on the tile editor, as it can now read in a .tsd file using the earlier developed data.c/data.h (Data, TileSetData, TileData, etc. structs and accompanying functions). Once a file is successfully loaded, changing the set/id will attempt to populate the GUI with key=>value pairs for the given tile, if it exists. Partially implemented is the parsing of InventoryData. Will implement adding new TablePairs through the GUI and the saving of any changes back to a .tsd file. Fixed some memory allocation problems as well - some leakage still existing in the tile editor as well as the Data functions/structs, but they are noted and will be taken care of in time. 2014-01-17 04:03:10 -08:00
kts 3b6160cb51 Spinner now has increment and decrement buttons, as well as mousewheel support. Mouse clicks now handled by the elements system rather than SDL. Tiles in the spritesheet view can now be clicked on, changing the currently focused tile id. 2014-01-15 05:52:36 -08:00
kts cfb2eda1c4 Added tile_editor/helper.c/.h to the Tile Editor target in xcode. Also removed tile_editor/.helper.c.swp file that accidentally was committed. 2014-01-15 00:32:48 -08:00
kts ae5cbb9b4e Tile editor becoming more functional. Set and id input now use the SpinnerElement type that only takes numerical input, increments or decrements via up/down keys, and runs its callback after any change. Currently loaded set's spritesheet shows in the right-hand side of the screen, resizing the screen accordingly. This spritesheet preview will be used as a way to load tile data visually rather than via tile ids. 2014-01-15 00:30:13 -08:00
kts 8570a9cca5 devcpp project files now updated to compile with parser types and functions. Also added the tile editor project, which produces a working win32/64 tile editor. 2014-01-09 21:54:53 -08:00
kts 874378c5a7 The tile editor now compiles and works on Linux/X11. Fixed quite a few memory allocation related problems and added code for free'ing Element(s). 2014-01-09 21:50:23 -08:00
kts 2c28c31bf8 Tile graphics may now be loaded by specifying the directory in the tile editor and pressing the load button. It will then look for doors.png, equips.png, floors.png, items.png, npcs.png, players.png, and walls.png. If any of these are not found, some or all of the graphic sets will be unavailable (the program iterates through them and returns if any fail, so if the 3rd tileset to be loaded fails, all thereafter will not load). The set and id can also be specified, after which the tile's graphic will be displayed. 2014-01-09 06:41:50 -08:00
kts b1aa56cade The tile editor has moved well beyond a skeleton, although much work is yet to be done. Added an Element struct for the tile_editor - basically the catch-all for input boxes, buttons, text fields, drop-down menus and so on. Fully functional is the button and text types, semi-functional (only visually) is text input (needs to be focus/editable), and non-existing are drop-down menus. The button callbacks for data and graphics loading do not actually load anything yet - will be done after text input, ofc. 2013-12-31 02:34:36 -08:00
kts 4ca32efeee Added an empty skeleton for the tile editor, including its own sub-directory in tile_editor/ (along with corresponding Makefile), as well as its own Target in timesynk's XCode project file. 2013-12-27 23:22:04 -08:00
kts f2422fdada added getTileDataById to data.h, as it was causing segfaults on gcc 4.2.1, mac os 10.6.8/x86 without it. Also fixed pack_data.c, as it was attempting to load the tile data directory before checking argc if an arg was passed. Also added equipment to ibexian shocktrooper and barbarian in xibalba/players for additional testing. 2013-12-24 06:01:43 -08:00
kts d5f4947c90 Yet again committed the sin of not committing for a long duration of time. As I recall: Finished most of the code for parsing a ts tile declaration file into data structures. In doing so added the InventoryData structure, which simply contains the name of the target tile, the count of tiles(using struct Range, which has min and max properties), the chance of spawn(using a float from 0.0 to 100.0), and an optional pointer to the next InventoryData in the line (akin to Tile Chains). Still todo is for TileData's TablePairs to be parsed into more than char*=>char* pairs, such as char*=>int, char*=>float, etc.. This will be far more efficient and given that TablePair(s) already contain the property for type, it should be done. Also added variations to addTablePair/setTablePair - addTablePairPointer and setTablePairPointer. These functions set the value pointer to the passed pointer rather than allocating new memory and copying the pointer's target memory to that new memory. 2013-12-24 05:37:15 -08:00
kts df13ab259f added pack_tiles.c, providing pack_tiles, a program that takes a directory as an argument and creates a new file (directory/directory.tsd) from cleaned files 'doors', 'floors', 'npcs', 'walls', 'equips', 'items', and 'players' in that directory. At the moment it can be used on the xibalba directory to create 'xibalba/xibalba.tsd', which can then be tested with test/t2d.c, providing the internal filename referenced is changed. At the moment the Data system does not properly deal with inventories so any inventory/equipment declaration is ignored. 2013-12-21 02:39:56 -08:00
kts c7f3ac15d3 added pack_tiles.c, providing pack_tiles, a program that takes a directory as an argument and creates a new file (directory/directory.tsd) from cleaned files 'doors', 'floors', 'npcs', 'walls', 'equips', 'items', and 'players' in that directory. At the moment it can be used on the xibalba directory to create 'xibalba/xibalba.tsd', which can then be tested with test/t2d.c, providing the internal filename referenced is changed. At the moment the Data system does not properly deal with inventories so any inventory/equipment declaration is ignored. 2013-12-21 02:38:08 -08:00
kts 0005a93d65 Implemented Data system fully now (not integrated into ts engine itself yet). In the process added a new Table (hash table) system that matches keys to values. More information pertaining to that in data.h/data.c. Might switch over to a system wherein all Tiles are actually TileData structs (or contain TileData structs). This would increase the processing necessary, as values for properties must be acquired from a string instead of reading from a pre-defined struct, but it would increase the modularity immensely as there is no real limit on the amount of properties a Tile may contain (which will be most important once the interpreter is implemented and used for tile movement, collisions, etc.). 2013-12-20 18:24:06 -08:00
kts e2e015c76b Added two folders: test/ and xibalba/. Contained within test/ are two test/devel-beds for two systems that will be integrated within ts. The first is script.c, which is the development program for the interpreter system - this interpreter system allows for the setting of variables (both local and global), the creation of new functions, and the definition of default in-game functions such as dice rolling and the like. The second file, t2d.c functions as a basic test utility for Tile Data loading and the like - it interprets a tileset/tile definition file into Data, TileDataSet, and TileData(s) respectively. These structs, as defined in data.c/.h, allow for reference to tiles by TID:ID or simply by name through the use of key=>value pairs. It is from these structs and their accompanying access functions that new Tiles will be created (perhaps later optimized through a basic Tile array that contains semi-populated Tile(s) that can be memcpy'd similar to the current system). Also added the xibalba/ sub-dir that will contain the various data for Xibalba (tile definitions, graphics, map creation, etc.), moving majority of what is in tiles/ into xibalba/. 2013-12-17 17:08:37 -08:00
kts b3a3831cd2 Added EquipTile/EQUIP. This distinguishes equipable items such as weapons, armour, rings, etc., from non-equipables such as keys and the like. 2013-11-27 18:31:49 -08:00
kts 770ad240e2 Updated Xcode to include parser.c/.h. Since it was not mentioned in last commit, parser.c/.h contains functions related to parsing slots, adding slots together, doing comparisons between slots, etc.. It is also where dice parsing and stat parsing will go as well. 2013-11-26 16:08:13 -08:00
kts ef59c0a365 Equipping and unequipping items now fully implemented. Uses the player's slots and used_slots properties along with the target item's required slots property. used_slots+required_slots are checked against slots and if less than, used_slots is changed accordingly. Unequipping removes required_slots from used_slots. equipmentContext added for equipping/unequipping as well. interface/sdl.c changed so that the focused UI (being either inventory or equipment) is at a higher opacity than the unfocused UI. 2013-11-26 16:02:04 -08:00
kts 375067aa8a Added some equipment-related code, but it needs to be reworked entirely. Equipment should just be an instance of Inventory, not its own struct. 2013-11-25 00:59:08 -08:00
kts d368c1efd0 Implemented the basic system for slots, stats, and damage wherein the type and amount of slots, stats, or die rolls are defined in their respective Tiles as a string. Although this has computational shortcomings due to parsing, it is the most flexible of all and forces no hard-coding on slot types or stat types. It can later be optimized, of course, as the size of each ItemTile, PlayerTile, and NpcTile has increased by at least 128 bytes. Note that some code is left-over from when the initial slot system was written using structs. Additionally, inventoryContext now handles up and down appropriately, and the inventory display has been improved. Along with the inventory display, an equipment surface is shown, although at the moment it lacks any equipment listing. 2013-11-23 03:28:38 -08:00
kts d10407fb38 Added functions descriptions in various *.c files. Should be in the header files, but for me, having the comments with the code is far better (since it's all in-development). interface/sdl.c should likely be split into multiple files, as it handles netcode, basic graphics operations, user input, and drawing the various UI elements all in one file. 2013-11-21 18:20:20 -08:00
kts bd67818190 Added tile_scale command that calls consoleScaleTiles(const char *string). This then converts the passed arguments of 'float x float y' (e.g., 'tile_scale 1.0 1.0' to scale to 1.0 times) to scaleTiles(float scale_x, float scale_y). If no argument is passed in the string, the default 2.0 scale is used. If the y property is not passed, the value of scale_x is used for scale_y. 2013-11-17 17:05:55 -08:00
kts 4e6f983db8 win32/64 uncovered out-of-bounds reading/writing for getpixel/putpixel in interface/sdl.c, so both functions now check if x/y is greater than or equal to 0 and less than or equal to the surface's width/height. 2013-11-17 16:37:10 -08:00
kts 7e7a4bd2fe Added drawScaledSpriteOutline function that (basically) draws an outline of the given sprite from the passed spritesheet. Although this function could later be used for drawing items/players behind tall objects, it is only used to outline the selected item while in the inventory screen at the moment. The function produces many warnings during compile, but they will be fixed later. Most of the draw*Sprite* functions should be combined - that is to say, drawScaledSprite and drawSprite should likely be the same function that chooses which spritesheet to use via a passed flag. 2013-11-17 16:02:49 -08:00
kts 81b566f9c8 No real changes, only minor tweaks to the trasparency of the inventory UI. 2013-11-16 23:23:43 -08:00
kts 2776c9a91c Updated devcpp projects to use inventory.c and inventory.h - works ok. 2013-11-16 16:22:43 -08:00
kts 6ad2ae9a5b NULL wasn't declared on non-xcode environment, so string.h was included (over stddef.h, as sprintf was required). Inventory window, such as it is, is created according to the max_slots/slots_per_row properties of the Inventory, thus adjusting for larger inventories. The current item's name is now shown at the center-bottom of the window. Dropping items is also tidier, as the inventory->selected property is adjusted if it is equal to count (i.e., the selected cursor is pushed back when the last item is removed so selected always corresponds to an existing item). 2013-11-16 16:15:22 -08:00
kts d50282effa We now have a mostly working inventory system. Items can be picked up via ` and dropped using ` within the inventory. Currently using a new playerPickup() function, but it should be abstracted to a tilePickup(struct Tile *tile) function so that npcs, etc., can share in the fun. 2013-11-16 04:41:06 -08:00
kts 4b7e0db3e0 Added rudimentary Inventory display, however we must have some way to keep track of the selected item in inventory offset. Perhaps through a global variable or, if it must be done, through a new Inventory struct that contains pertinent information. It should likely be the latter, so the same system can be expanded to chests and the like. Also added the ITEM type in general. 2013-11-16 02:15:03 -08:00
kts 57a1b46db4 Created a new Spritesheet struct for loading and managing spritesheets - has two SDL_Surfaces, one scaled, the other original. Also has various properties related to scale size, columns in a row, etc.. Changed interfaceDraw() to use the new system. Also, the tile in front of the player is drawn at partial opacity if it is a WALL or a DOOR. Moved the position of the UI around. 2013-11-15 18:19:54 -08:00
kts 981e0cd2f2 Added SDL_image.framework as a framework to include in the produced app, thus allowing timesynk.app to run w/o dependencies. 2013-11-15 14:00:26 -08:00
kts 81c3ea6fdc Moved a portion of the user messages (e.g., 'You open the %s.') to various #define MESSAGE_* in message.h. Also fixed the bug I never looked into where entries in consoleLog would read past the string into neighboring memory - this was due to using strlen(string) for the byte-length in memcpy, as strlen does not count the terminating character '\0'. Fixed by adding +1 to the return value of strlen 2013-11-14 16:21:53 -08:00
kts 23455ccd5c Tidied up interface/sdl.h somewhat. Fixed most of the compiler warnings from interface/sdl.c. Also touched up font_mini.png to make it a bit more readable. 2013-11-14 15:15:42 -08:00
kts 8893eb35d4 Did a hack to get transparency working on big endian systems - basically it grabs a portion of the pixel color value and uses that for alpha. This is terrible, but I did not want to waste time trying to figure out what was wrong, as it is more of a tertiary feature. Beyond that, added a new font_mini.png spritesheet that contains an 8x8 ASCII font. This is currently used in the new UI messages system, which is basically a window that is drawn over the map with the current in-games messages. At some point this will be split into two different categories, one from the PC perspective and the other from the player perspective (e.g., 'you bludgeon the nupi' - '4 damage (1d6+1)'). Also added a new Font struct that contains: int width, int height, SDL_Surface *spritesheet, float scale_x, float scale_y, and SDL_Surface *scaled_spritesheet. Helper function added of loadFontFromMemory(struct Font *font, unsigned char *memory, unsigned int length, int font_width, int font_height) - this creates a new SDL_Surface from the passed memory and sets the passed font's surface to it along with the width and height. Also added was a setFontScale(struct Font *font, float scale_x, float scale_y) - this calls interfaceScaleSurface on the font's spritesheet and sets scaled_spritesheet to point to that new surface. For the time being, the new font is used through interfaceDrawStringF and interfaceDrawCharF, two functions that closely match their normal counterparts, but instead use a passed font and its values for drawing. The normal draw char/string functions will likely be replaced with the new ones. 2013-11-14 03:03:10 -08:00
kts d7ad2c3bd6 Added uiInit(), a function that creates ui_hotbar_surface, blits the appropriate ui.png sprites to it, then sets the opacity to 0.75. At the moment, ui.png must be in RGBA format due to my lack of knowledge on alpha blending, etc. - this shall be changed later for optimization. Added the SDL_SetOpacity(SDL_Surface *surface, double opacity) function that sets the alpha layer of the target surface to the desired amount. Along with this is the uiSetOpacity helper, which simply calls SDL_SetOpacity on ui_hotbar_surface. Also added uiSetScale which simply calls interfaceScaleSurface(SDL_Surface *surface, float x, float y) on ui_hotbar_surface. interfaceScaleSurface does a rough up/down-scale of the target surface - has not been thoroughly tested for bugs, so it has the potential to break. 2013-11-12 02:41:32 -08:00
kts 0c24fedfb2 Added some rudimentary UI related stuff: ui.png with the first 32x32 section being a hotbar item; uiDraw(), which draws hotbar_count(value to be controlled by amount of items w/ slots the player has (e.g., belt, slotted glove, etc.)) amount of hotbar item images at partial translucency. Also added hitting 'i' to switch to/draw the inventoryContext - at the moment, it does nothing more than cause an SDL_Rect to be drawn and switch to inventoryContext (which does nothing in itself). 2013-11-11 02:35:47 -08:00
kts 639d4b9fcb Added a preprocessor conditional for OS X for SDL_Init, as SDL_INIT_EVENTTHREAD causes the program to become unresponsive (although still tick the world) akin to Win32/64. Fixed a crash when activating a non-existent Tile, as it would simply attempt to read the null tile. 2013-11-10 02:48:57 -08:00
kts 1c6389866b Fixed some leaks and re-enabled freeMap. 2013-11-10 02:06:17 -08:00
kts cf94f135c6 Added tile scaling via interfaceSetScale. This currently modifies the various spritesheet->Surface(s) loaded from tiles.c/pack_tiles, but they should modify live alternatives, so that changes always start from the original surfaces. Also created shading on the rock wall, created a new palisade wall, and also fixed/prettified the current doors. 2013-11-10 01:01:07 -08:00