Home » MODDING HQ 1.13 » Flugente's Magika Workshop » New feature: Improved trade menu
New feature: Improved trade menu[message #349019] Sun, 26 February 2017 18:44 Go to next message
Flugente

 
Messages:3482
Registered:April 2009
Location: Germany
While my previous ideas to improve the trade menu were well received, as usual nobody was willing to implement them, so I did. This is pretty much exactly what proposed - the trade menu is now resolution-dependent. Observe:

http://i.imgur.com/qRRQA7p.png
1600x1024

http://i.imgur.com/7ZHjnbW.png
640x480

This of course works in any resolution. As a result, this is not optional. I've altered huge parts of that code and have no intention to go the usual 'we make things optional for no reason' route.

I've also added the colouring of items that can't be sold, stacking of additional items and the display of the merchant budget.

The only thing not implemented in the afore-mentioned post is the sector inventory access. As usual, the strategic inventory is not wrapped at all, which means I'd have to recreate that entire thing, which I'd loathe to. Additionally, accessing sector inventory in tactical would cause quite a few internal problems I have no motivation to solve right now.

This has been added to the trunk in r8389 and is fully savegame compatible.



I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.


Re: New feature: Improved trade menu[message #349021 is a reply to message #349019] Sun, 26 February 2017 18:58 Go to previous messageGo to next message
Xafloz

 
Messages:85
Registered:December 2016
In bigger resolutions items may become rather small. Do you plan to introduce a magnifying glass like the one in sector inventory? Great improvement anyway.
Re: New feature: Improved trade menu[message #349251 is a reply to message #349021] Sun, 12 March 2017 20:09 Go to previous messageGo to next message
Xafloz

 
Messages:85
Registered:December 2016
Observation: unfortunately the feature freezes the game in 1920x1080 (when you click BUY in any merchant dialogue). This resolution is very useful for 4k monitors and so far I have been play countless hours using this one on 4k monitor. In smaller resolutions the feature works as intended, but visual effect of the game as a whole is not so good.

[Updated on: Sun, 12 March 2017 20:10]

Re: New feature: Improved trade menu[message #349252 is a reply to message #349251] Sun, 12 March 2017 22:20 Go to previous messageGo to next message
Flugente

 
Messages:3482
Registered:April 2009
Location: Germany
Eh? I'm playing with that resolution and get no error at all.

Items in shopkeeper inventory aren't bigger or smaller than those in merc inventories. I see no reason to change that.



I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.


Re: New feature: Improved trade menu[message #349255 is a reply to message #349252] Sun, 12 March 2017 23:06 Go to previous messageGo to next message
Xafloz

 
Messages:85
Registered:December 2016
Well I tried on pure new 8390. The same result at my end. Maybe it`s just Radeon "antymagic" or something connected with my specific configuration, but as I said it works form me in lower res.
Re: New feature: Improved trade menu[message #350519 is a reply to message #349255] Wed, 09 August 2017 23:27 Go to previous messageGo to next message
Flugente

 
Messages:3482
Registered:April 2009
Location: Germany
Because some people are not happy with a simple clean grey background, and I strongly dislike the Sirtech way of creating backgrounds for huge panels of unknown size - using a smaller image over and over again as if tiling a roof - I've decided to simply generate something different (r8444).

http://i.imgur.com/lPPn5Qf.png

The background is now a texture generated via random noise. The texture is generated anew once every use of an exe. I could also generate it constantly (so we would have a moving, swirling background), but this shall suffice.

If anybody is still unhappy about these colours, let me point out that I can still change my mind and have it simply be neon-pink.

[Updated on: Wed, 09 August 2017 23:29]




I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.


Re: New feature: Improved trade menu[message #350530 is a reply to message #350519] Thu, 10 August 2017 16:25 Go to previous messageGo to next message
smeagol

 
Messages:2733
Registered:June 2008
Location: Bremen, Germany
Much better... but why use 3 different colours?


Re: New feature: Improved trade menu[message #350538 is a reply to message #350530] Thu, 10 August 2017 20:23 Go to previous messageGo to next message
Flugente

 
Messages:3482
Registered:April 2009
Location: Germany
To better tell apart the different areas of the screen.



I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.


Re: New feature: Improved trade menu[message #350544 is a reply to message #349019] Fri, 11 August 2017 12:04 Go to previous messageGo to next message
grim

 
Messages:341
Registered:July 2006
Location: France
Legit.

By the way, another old idea made real by you, Flugente.
Thank you, much respect!
Re: New feature: Improved trade menu[message #350755 is a reply to message #350544] Sat, 26 August 2017 18:52 Go to previous messageGo to next message
Flugente

 
Messages:3482
Registered:April 2009
Location: Germany
Due to the considerable slowdown mentioned in this thread, as of r8457 & GameDir r2385, the trade menu background is no longer generated by random noise, but by cutting out a section of a much bigger picture.

http://i.imgur.com/8C87eOX.png

This should remove any speed issues. The picture used has a size of 3088x2056. This should suffice for resolutions up to ~5544x3540. If you have a screen with a bigger resolution, you need to add a picture with higher dimensions. You are also spending waaaay to much money on monitors.

Keep in mind that you will need the new picture that comes with GameDir r2385 when using the new exe.

[Updated on: Sat, 26 August 2017 18:55]




I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.


Re: New feature: Improved trade menu[message #358698 is a reply to message #349019] Sat, 21 December 2019 16:10 Go to previous message
bfant

 
Messages:6
Registered:December 2019
Hi,

I modified your trade menu slightly to also show the names of the items, since there are too many (near) identical looking items (e.g. AK variants, some types of ammo boxes, etc.). I increased the height of the inventory boxes slightly (4 pixels) in order to better fit the text. The item text is also slightly overlapping with the item graphic to save space.

Here's a screenshot:

http://i.imgur.com/Qw1xJFR.jpg

Patch against SVN version 8718:

Index: Tactical/ShopKeeper Interface.cpp
===================================================================
--- Tactical/ShopKeeper Interface.cpp	(revision 8718)
+++ Tactical/ShopKeeper Interface.cpp	(working copy)
@@ -102,14 +102,14 @@
 
 //Inventory Slots size and offsets
 #define		SKI_INV_SLOT_WIDTH								67
-#define		SKI_INV_SLOT_HEIGHT								31
+#define		SKI_INV_SLOT_HEIGHT								35		// bfant: increased from 31 to fit item name text
 #define		SKI_INV_HEIGHT									(SKI_INV_SLOT_HEIGHT - 7)
 #define		SKI_INV_WIDTH									60
 #define		SKI_INV_OFFSET_X								74
-#define		SKI_INV_OFFSET_Y								36
+#define		SKI_INV_OFFSET_Y								40		// bfant: increased from 36
 
 #define		SKI_INV_PRICE_OFFSET_X							1
-#define		SKI_INV_PRICE_OFFSET_Y							24
+#define		SKI_INV_PRICE_OFFSET_Y							28		// bfant: increased from 24 to fit item name text
 
 // the delay for glow cycling in glow areas, in millisecs
 #define		SKI_GLOW_DELAY 70
@@ -129,7 +129,7 @@
 #define		SKI_DEALER_OFFER_AREA_Y								(SCREEN_Y_OFFSET + 148)
 
 #define		SKI_ITEM_NUMBER_TEXT_OFFSET_X					50
-#define		SKI_ITEM_NUMBER_TEXT_OFFSET_Y					15
+#define		SKI_ITEM_NUMBER_TEXT_OFFSET_Y					19		// bfant: increased from 15 to fit item name text
 #define		SKI_ITEM_NUMBER_TEXT_WIDTH						15
 
 #define		SKI_SUBTITLE_TEXT_SIZE								512
@@ -220,7 +220,7 @@
 #define		SKI_TRADER_OFFER_BEGIN_X			SKI_TOTAL_BEGIN_X
 #define		SKI_TRADER_OFFER_BEGIN_Y			SKI_TRADER_INVENTORY_END_Y
 #define		SKI_TRADER_OFFER_END_X				SKI_TOTAL_END_X
-#define		SKI_TRADER_OFFER_END_Y				(82 + SKI_TRADER_INVENTORY_END_Y)
+#define		SKI_TRADER_OFFER_END_Y				(90 + SKI_TRADER_INVENTORY_END_Y)	// bfant: adjusted so 2 rows fit again after item text modification
 
 // trader offer area item boxes
 #define		SKI_TRADER_OFFER_BOXES_BEGIN_X		(SKI_TRADER_OFFER_BEGIN_X + 91)
@@ -1310,6 +1310,32 @@
 #endif
 }
 
+// Internal function to draw shop keeper inventory boxes
+void DrawShopKeeperInventoryBox(INT32 usPosX, INT32 usPosY)
+{
+	static const UINT16 col_itembox = Get16BPPColor(FROMRGB(74, 65, 49));
+	static const UINT16 col_itemdescription = Get16BPPColor(FROMRGB(181, 150, 74));
+	static const UINT16 col_itemstatusbar = Get16BPPColor(FROMRGB(57, 56, 41));
+
+	// draw background for status bar
+	ColorFillVideoSurfaceArea(FRAME_BUFFER, 
+		usPosX, usPosY,
+		usPosX + 4, usPosY + 28,
+		col_itemstatusbar);
+
+	// draw background for picture of item, etc.
+	ColorFillVideoSurfaceArea(FRAME_BUFFER,
+		usPosX + 4, usPosY,
+		usPosX + SKI_INV_SLOT_WIDTH, usPosY + 28,
+		col_itembox);
+
+	// draw background for money area
+	ColorFillVideoSurfaceArea(FRAME_BUFFER,
+		usPosX, usPosY + 28,
+		usPosX + SKI_INV_SLOT_WIDTH, usPosY + SKI_INV_SLOT_HEIGHT,
+		col_itemdescription);
+}
+
 BOOLEAN RenderShopKeeperInterface()
 {
 	CHAR16	zMoney[128];
@@ -1420,18 +1446,8 @@
 
 			for ( int x = 0; x<SKI_TRADER_INVENTORY_BOXES_PER_ROW; ++x )
 			{
-				ColorFillVideoSurfaceArea( FRAME_BUFFER, usPosX, usPosY,
-										   (INT16)(usPosX + 4), (INT16)(usPosY + 24),
-										   col_itemstatusbar );
+				DrawShopKeeperInventoryBox(usPosX, usPosY);
 
-				ColorFillVideoSurfaceArea( FRAME_BUFFER, (INT16)(usPosX + 4), usPosY,
-										   (INT16)(usPosX + SKI_INV_SLOT_WIDTH), (INT16)(usPosY + 24),
-										   col_itembox );
-
-				ColorFillVideoSurfaceArea( FRAME_BUFFER, usPosX, (INT16)(usPosY + 24),
-										   (INT16)(usPosX + SKI_INV_SLOT_WIDTH), (INT16)(usPosY + SKI_INV_SLOT_HEIGHT),
-										   col_itemdescription );
-
 				usPosX += SKI_INV_OFFSET_X;
 			}
 			usPosY += SKI_INV_OFFSET_Y;
@@ -1446,18 +1462,8 @@
 
 			for ( int x = 0; x<SKI_TRADER_OFFER_BOXES_PER_ROW; ++x )
 			{
-				ColorFillVideoSurfaceArea( FRAME_BUFFER, usPosX, usPosY,
-										   (INT16)(usPosX + 4), (INT16)(usPosY + 24),
-										   col_itemstatusbar );
+				DrawShopKeeperInventoryBox(usPosX, usPosY);
 
-				ColorFillVideoSurfaceArea( FRAME_BUFFER, (INT16)(usPosX + 4), usPosY,
-										   (INT16)(usPosX + SKI_INV_SLOT_WIDTH), (INT16)(usPosY + 24),
-										   col_itembox );
-
-				ColorFillVideoSurfaceArea( FRAME_BUFFER, usPosX, (INT16)(usPosY + 24),
-										   (INT16)(usPosX + SKI_INV_SLOT_WIDTH), (INT16)(usPosY + SKI_INV_SLOT_HEIGHT),
-										   col_itemdescription );
-
 				usPosX += SKI_INV_OFFSET_X;
 			}
 			usPosY += SKI_INV_OFFSET_Y;
@@ -1472,18 +1478,8 @@
 
 			for ( int x = 0; x<SKI_PLAYER_OFFER_BOXES_PER_ROW; ++x )
 			{
-				ColorFillVideoSurfaceArea( FRAME_BUFFER, usPosX, usPosY,
-										   (INT16)(usPosX + 4), (INT16)(usPosY + 24),
-										   col_itemstatusbar );
+				DrawShopKeeperInventoryBox(usPosX, usPosY);
 
-				ColorFillVideoSurfaceArea( FRAME_BUFFER, (INT16)(usPosX + 4), usPosY,
-										   (INT16)(usPosX + SKI_INV_SLOT_WIDTH), (INT16)(usPosY + 24),
-										   col_itembox );
-
-				ColorFillVideoSurfaceArea( FRAME_BUFFER, usPosX, (INT16)(usPosY + 24),
-										   (INT16)(usPosX + SKI_INV_SLOT_WIDTH), (INT16)(usPosY + SKI_INV_SLOT_HEIGHT),
-										   col_itemdescription );
-
 				usPosX += SKI_INV_OFFSET_X;
 			}
 			usPosY += SKI_INV_OFFSET_Y;
@@ -2739,7 +2735,8 @@
 #endif
 
 	//Display the status of the item
-	DrawItemUIBarEx( pItemObject, 0, (INT16)(usPosX+2), (INT16)(usPosY+2+20), 2, 20, 	Get16BPPColor( FROMRGB( 140, 136, 119 ) ), Get16BPPColor( FROMRGB( 140, 136, 119 ) ), TRUE, guiRENDERBUFFER );//guiSAVEBUFFER
+	//bfant: adjusted size of status bar for item text
+	DrawItemUIBarEx( pItemObject, 0, (INT16)(usPosX+2), (INT16)(usPosY+2+24), 2, 24, 	Get16BPPColor( FROMRGB( 140, 136, 119 ) ), Get16BPPColor( FROMRGB( 140, 136, 119 ) ), TRUE, guiRENDERBUFFER );//guiSAVEBUFFER
 	
 	//Display the Items Cost
 	if( ubItemArea == PLAYERS_OFFER_AREA )
@@ -2825,6 +2822,16 @@
 		DrawTextToScreen( zTemp2, (UINT16)(usPosX+SKI_INV_PRICE_OFFSET_X), (UINT16)(usPosY+SKI_INV_PRICE_OFFSET_Y), SKI_INV_SLOT_WIDTH, SKI_ITEM_DESC_FONT, SKI_ITEM_PRICE_COLOR, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED );
 	}
 
+	/////////////////////
+	// bfant: Display item name, limited to displayable characters (space constraints)
+	if (pItem->szItemName != 0)
+	{
+		wcsncpy(zTemp, pItem->szItemName, sizeof(zTemp) / 2);
+		zTemp[63] = '\0';  // make sure it is null-terminated
+		ReduceStringLength(zTemp, SKI_INV_SLOT_WIDTH - 2, BLOCKFONTNARROW);
+		DrawTextToScreen(zTemp, usPosX, usPosY + 1, SKI_INV_SLOT_WIDTH, BLOCKFONTNARROW, SKI_ITEM_PRICE_COLOR, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED);
+	}
+
 	//if the there is more then 1 or if the item is stackable and some of it has been bought and only 1 remains
 	if( ( pItemObject->ubNumberOfObjects > 1 ) ||
 			( ( pItemObject->ubNumberOfObjects == 1 ) &&
@@ -3895,7 +3902,7 @@
 		{
 			INT32 balance = LaptopSaveInfo.iCurrentBalance;
 			if ( armsDealerInfo[gbSelectedArmsDealerID].uiFlags & ARMS_DEALER_DEALWITHINTEL )
-				balance = GetIntel();
+				balance = (INT32)GetIntel();
 
 			//if the player doesn't have enough money in his account to pay the rest
 			if( uiArmsDealersItemsCost > uiPlayersTotalMoneyValue + balance )
@@ -5416,7 +5423,7 @@
 			
 	INT32 balance = LaptopSaveInfo.iCurrentBalance;
 	if ( armsDealerInfo[gbSelectedArmsDealerID].uiFlags & ARMS_DEALER_DEALWITHINTEL )
-		balance = GetIntel();
+		balance = (INT32)GetIntel();
 
 	if( uiArmsDealerTotalCost > uiPlayersOfferAreaTotalCost + balance )
 	{
@@ -5951,7 +5958,7 @@
 		//Perform the transaction with the extra money from the players account
 		PerformTransaction( iMoneyToDeduct );
 
-		AddIntel( -iMoneyToDeduct, TRUE );
+		AddIntel( (FLOAT)-iMoneyToDeduct, TRUE );
 	}
 
 	// done, re-enable calls to PerformTransaction()

[Updated on: Wed, 25 December 2019 13:30] by Moderator

Previous Topic: New feature: additional dialogue
Next Topic: New feature: Externalised Merchants
Goto Forum:
  


Current Time: Sun Jan 26 08:27:59 EET 2020

Total time taken to generate the page: 0.01605 seconds