首页 > REDM基础教程 > REDM基础教程12-手工增加皮肤
2016十一月13

REDM基础教程12-手工增加皮肤

[隐藏]

  上一节的Test+MyRes+QQPW图片下载–>

Test.zip

MyRes1.zip

QQPW.zip

 修改后的MyRes下载–>

MyRes.zip

 

  

  

1.手工增加皮肤

  

1.1.手工增加img

   

从前面的设计增加皮肤的流程可以看出,首先我们应该增加img,img的保存路径均由主题包的dmindex.xml来配置(它总是位于主题包的根目录),如果你还是找不到,可以结合设计器,右击主题包名称,选择打开目录

1.png

  

dmindex.xml的内容如下:

<?xml version="1.0"?>
<resource>
	<gif>
		<file name="qqbg" path="themes\theme0\qqbg.gif" />
	</gif>
	<png>
		<file name="close" path="themes\theme0\image\close.png" />
		<file name="mini" path="themes\theme0\image\mini.png" />
		<file name="QQlogin" path="themes\theme0\image\QQlogin.png" />
		<file name="QQ" path="themes\theme0\image\QQ.png" />
		<file name="QQleft" path="themes\theme0\image\QQleft.png" />
		<file name="QQright" path="themes\theme0\image\QQright.png" />
		<file name="QQcbxbg" path="themes\theme0\image\QQcbxbg.png" />
		<file name="QQcheckbox" path="themes\theme0\image\QQcheckbox.png" />
		<file name="QQbtn" path="themes\theme0\image\QQbtn.png" />
	</png>
</resource>

 

结合设计器的展示图,设计器有一点缺陷,就是只展示了文件名,但未展示文件的name,后期考虑修正

2.png

  

所以我们手工加入一条name为QQPW的img

1.在png节点下加入:(name其实可以不叫QQPW,如果使用别的name,我们需要记住它, 因为皮肤中需要通过name来查找img文件)

<file name="QQPW" path="themes\theme0\image\QQPW.png" />

2.将QQPW.png拷贝到themes\theme0\image\这个目录下

3.记得保存好dmindex.xml,这时我们的img就添加完成了

  

如果你同时使用设计器打开了MyRes,请按下F5键,设计器会重新加载MyRes文件夹,这是个非常有用的操作

  

  

   

2.手工增加皮肤  

   

皮肤分为两类,一类是全局皮肤,一类是私有皮肤,私有皮肤位于某个特定窗口的XML上,仅在特定窗口创建时才会解析加入,而且我们可以在这个窗口销毁时释放它的私有皮肤,目的是为了节省内存空间

全局皮肤的XML由layout\dmindex.xml中的<global>节点来指定,只允许一份,如我们的MyRes中layout\dmindex.xml

<?xml version="1.0"?>
<resource>
	<global>
		<file name="global" path="layout\xml\global.xml" />
	</global>
	<layout>
		<file name="main" path="layout\xml\main.xml" />
	</layout>
</resource>

很明显,我们的全局皮肤XML是MyRes\layout\xml\global.xml,它的唯一标识lpszXmlIdglobal,在Test.cpp中使用以下代码来初始化它

	theApp.InitGlobal();-->
	原型:DMCode InitGlobal(LPCWSTR lpszXmlId=L"global");

  

同样,如果你打开了设计器,依次选中:样式-皮肤(全局)列表–>皮肤池(全局)列表–>打开目录,同样会跳转选中global.xml

3.png

  

global.xml的内容如下:

<?xml version="1.0"?>
<global font="face:宋体,size:14,weight:400,charset:0,underline:0,italic:0,strike:0">
	<skin name="baseskin">
		<imglist id="close" src="png:close" states="3" bvert="0" btitle="0" />
		<imglist id="mini" src="png:mini" states="3" bvert="0" btitle="0" />
		<imglist id="QQlogin" src="png:QQlogin" states="1" bvert="0" btitle="0" />
		<imglist id="QQ" src="png:QQ" states="1" bvert="0" btitle="0" />
		<imglist id="QQleft" src="png:QQleft" states="3" bvert="0" btitle="0" />
		<imglist id="QQright" src="png:QQright" states="3" bvert="0" btitle="0" />
		<imglist id="QQcbxbg" src="png:QQcbxbg" states="1" bvert="0" btitle="0" />
		<imglist id="QQcheckbox" src="png:QQcheckbox" states="8" bvert="0" btitle="0" />
		<imglist id="QQbtn" src="png:QQbtn" states="3" bvert="0" btitle="0" />
	</skin>
	<style />
</global>

 

结合设计器的展示图

4.png

  

所以我们手工加入一条id为QQPW(id="QQPW")的皮肤到skin节点下,使用png类型下的name为QQPW的img(src="png:QQPW"),使用状态连图(xml结点为imglist),状态数为3(states="3"),水平连图(bvert="0"),拉伸绘制(btitle="0")

<imglist id="QQPW" src="png:QQPW" states="3" bvert="0" btitle="0" />// bvert,btitle可不写,因为内置默认就是0

记得保存下global.xml,如果你同时打开了设计器,按F5重新加载,即可以发现QQPW这个皮肤已存在

   

  下一节教程:REDM基础教程13-手工增加控件

   

     

文章作者:hgy413
本文地址:http://hgy413.com/3744.html
版权所有 © 转载时必须以链接形式注明作者和原始出处!

15 Responses to “REDM基础教程12-手工增加皮肤”

  1. #1 minecraft 回复 | 引用 Post:2018-10-05 00:03

    Fantastic beat ! I would like to apprentice at the same time as you amend your site, how could i subscribe for a blog site?
    The account helped me a appropriate deal. I were a little bit familiar of this
    your broadcast offered vivid transparent concept

  2. I am sure this article has touched all the internet users, its really really fastidious piece of writing on building up new blog.

  3. #3 Benefits of Coconut Oil 回复 | 引用 Post:2018-10-24 07:11

    For newest information you have to pay a quick visit world wide web and on world-wide-web I found this web site as
    a finest web page for newest updates.

  4. Hi there colleagues, good post and nice arguments commented at
    this place, I am really enjoying by these.

  5. Descargar facebook
    I have been browsing online more than 3 hours today, yet I never found any
    interesting article like yours. It’s pretty worth enough for me.
    Personally, if all website owners and bloggers made good content as you did, the web will be much more
    useful than ever before. Descargar facebook

  6. #6 quest bars cheap 回复 | 引用 Post:2018-11-03 11:59

    Its like you read my thoughts! You seem to understand a lot
    approximately this, like you wrote the e book in it or something.
    I think that you simply can do with a few p.c. to force the
    message home a bit, but other than that, this is magnificent blog.
    A great read. I’ll definitely be back.

  7. #7 quest bars cheap 回复 | 引用 Post:2018-11-04 22:09

    Quest bars cheap fitnesstipsnew1 quest bars cheap 516999410492780544 quest bars cheap
    It’s really a nice and useful piece of info. I am glad that
    you just shared this helpful information with us.
    Please stay us informed like this. Thank you for sharing.
    Quest bars cheap fitnesstipsnew1 quest bars cheap 516999410492780544 quest bars
    cheap

  8. #8 Quest Protein Bars 回复 | 引用 Post:2018-11-06 04:54

    Very nice write-up. I definitely love this site.

    Thanks!

  9. Good info. Lucky me I ran across your site by chance (stumbleupon).
    I have book marked it for later!

  10. You actually make it appear really easy along with your
    presentation however I in finding this matter to be really something that
    I think I would by no means understand. It kind of feels too complex and very broad for me.

    I am taking a look forward to your next publish, I will try to get the hang of
    it!

  11. My brother recommended I would possibly like this website.
    He used to be entirely right. This put up truly made my day.
    You can not believe simply how a lot time I had spent for this information! Thank
    you!

  12. #12 Sling TV 回复 | 引用 Post:2018-11-14 11:49

    You’re so interesting! I don’t suppose I’ve read
    a single thing like this before. So great to discover someone with
    unique thoughts on this issue. Really.. thanks for starting this up.
    This website is one thing that’s needed on the web, someone with a little
    originality!

  13. Hello there! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche.

    Your blog provided us useful information to work on. You have done a wonderful
    job!

  14. Its like you learn my mind! You seem to understand so much about this, like you wrote the guide in it
    or something. I think that you could do with some percent
    to power the message house a little bit, however instead of that, that
    is great blog. An excellent read. I will certainly be back.

  15. Thanks for sharing such a nice thought, post is good, thats
    why i have read it completely

发表评论