Author: mordante
Date: Sat Nov 1 17:43:24 2008
New Revision: 30500
URL: http://svn.gna.org/viewcvs/wesnoth?rev=30500&view=rev
Log:
Also expose the original size of the image.
The formulas might want to know about the original size of the image
especially since height and width can't be used to set the width or
height of the image (if it needs to be scaled by a factor).
Modified:
trunk/src/gui/widgets/canvas.cpp
Modified: trunk/src/gui/widgets/canvas.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/canvas.cpp?rev=30500&r1=30499&r2=30500&view=diff
==============================================================================
--- trunk/src/gui/widgets/canvas.cpp (original)
+++ trunk/src/gui/widgets/canvas.cpp Sat Nov 1 17:43:24 2008
@@ -574,6 +574,12 @@
* the y (or x) value of the image. (This
* means x and y are evaluated after the
* width and height.)
+ * image_original_width unsigned The width of the image as stored on
+ * disk, can be used to set x or w
+ * (also y and h can be set).
+ * image_original_height unsigned The height of the image as stored on
+ * disk, can be used to set y or h
+ * (also x and y can be set).
* @end_table
* Also the general variables are available, see [[#general_variables|Line]].
*
@@ -632,10 +638,14 @@
// so leave silently.
return;
}
- unsigned w = w_(variables);
- unsigned h = h_(variables);
game_logic::map_formula_callable local_variables(variables);
+ local_variables.add("image_original_width", variant(image_->w));
+ local_variables.add("image_original_height", variant(image_->h));
+
+ unsigned w = w_(local_variables);
+ unsigned h = h_(local_variables);
+
local_variables.add("image_width", variant(w ? w : image_->w));
local_variables.add("image_height", variant(h ? h : image_->h));
const unsigned x = x_(local_variables);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits