Game uidesign and Analysis 1

Source: Internet
Author: User

After several times, I decided to write something to make him despise me, so that he could be ignored.

In the first article, I plan to talk about my recent experiences, the trade-offs of Some Problems in game UI design, and the similar analysis of cegui source code and design ideas. Let's talk about cegui this time.

 

Currently, many domestic games are using it, and many open-source projects also recommend it. It is very popular and excellent, I am very grateful to crazy edit for writing such an excellent general game UI library and open-source Learning for these many cainiao. Before getting started, let's talk about the Chinese solution sent from the Internet, as well as some small problems I found.

1. Chinese solutions:

The cegui string uses 32-bit unsigned int internally. Therefore, it is designed to support Chinese characters, but why is it wrong to use Chinese? I am talking about how to use Win32 API to convert the format encoding on the Internet. In fact, this does not solve the problem. I have encountered constant questions about why I have not solved it. I am using it well. Well, I can only say that you have never processed Chinese strings through the Lua script. Pair ~ The essence of errors is most obvious here. Although the Lua script file uses utf8 encoding and supports Chinese characters, the Lua and C interfaces have converted utf8 encoding into ANSI, the string c_str of cegui outputs utf8 encoding. Therefore, errors may occur. The solution is also so easy. Modify c_str and replace the macro In The Lua script header file, OK. The second question about Chinese is Chinese Input. If you make an IME judgment during inject char, it will be OK.

2. minor issues:

The first is the cegui text encoding map. During data exchange with XML, the uint is forcibly converted to int. Therefore, if the text encoding is greater than 0x7fffffff, an error occurs.

The second is what I encountered when optimizing the rendering efficiency. Some controls in the cegui do not have the Z layer settings and are completely dependent on the order of components draw. Although the operation will not go wrong, but it is also a small problem.

 

Now let's talk about my views on cegui and analysis of some problems. cegui is flexible, flexible, and flexible. Therefore, people who use cegui often encounter some inexplicable problems. In fact, they have a deep understanding of cegui, which is not a problem, but if they are used as a class library, it exposes a problem and the interface design is prone to misuse, which is unreasonable. As a programmer of such Nb, everyone thinks that the class library of Nb has such problems that will be discovered by people who have read effect c ++?

The reason is that there is a serious risk of data inconsistency in the cegui. If you carefully study the source code, you will find that there are a large number of references between objects, which are the source of data inconsistency. (when I first studied the cegui source code, I thought again, why don't we have to manage pointers, later, I understood various types of pai_ptr, weak_ptr, oh... Disaster) database doesn't mean consistency constraints, but why? Because there are too many solutions to a problem. Let me give you an example. How can we create a blood strip. I will talk about several typical practices.

 

According to the general thinking, we will pile up controls. The cegui supports well and the editor can also be used. On the surface, the prefect cannot be found. What is the actual situation? The cegui example contains an example of mine clearance. You can trace the source code. After all the mine points are opened, each frame's DP is nearly 200 times! 200 times? Concept... The problem is that all controls in cegui are hierarchical, and each control has its own independent Z-value space. Therefore, if the control is stacked, switching the rendering status is a disaster.

 

Further, you may find that each cegui control has three components, namely frame, text, and image. Here, I will make an article to get all the static things up, in the same Z space, dynamic, Property Control. Well, this solution is close to the limit of cegui.

 

Even more crazy, the componet of cegui has operators. Oh, my God... Is it a scripting language... For example, the texture width is directly set in the skin file using a mathematical expression when the blood strip is displayed. Well, this is perfect ....

 

A complex online game head is displayed, two DP times, everything is OK. But the complexity of this production... And there is no editor, let's say exactly... Who will make the editor so flexible... As someone said, only scripts can control everything. The UI is just for children. Well, I think cegui is close to that too...

 

After talking about these problems, it doesn't mean that cegui is not good, but that it is very good and powerful, but that it is not suitable for him? My opinion is not suitable. For example, if you write a rendering demo, will you use dxut or cegui. I think there is no suspense, dxut.

 

Some people will say that I maintain the cegui so well that I cannot write anything better than him. I try to make it easy to use. In fact, this is my previous understanding. Now I don't think it's okay. I think the cost may be similar to maintaining cegui. Let's talk about the many unsolved problems of cegui. The Chinese display input is not enough.

 

Cegui's Chinese cache mechanism is a disaster. I think everyone knows, well, a font size, dozens of MB of memory, and so on.

The most simple method of cegui's animation support is 0, which is not supported at the underlying layer... Cost... Refresh the quadlist. Here I want to emphasize one point. I think the cegui cache design is unreasonable. The text is separated from the image, so that every time you refresh the quadlist, a large amount of texture computing is required for the text, the chances of a quadlist refresh is much higher than that of clearing the cache for re-computing. Why not put this small amount of computing in the cache. We will continue to talk about animation support. In analyticdb 0.6, We have a task interface, which I think many people know and have implemented by themselves. But how much can this task do? Not much. It's a conventional window animation. Can it be a little dazzling? No, it's just a particle system. Yes, but it can be a little more dazzling. Let's change the quad in render. Since the quadrilateral is in the cache, why should we keep providing this quadrilateral to render.

The efficiency of cegui is good after trying every means in rendering. However, I talked to some Daniel and found another bottleneck after testing with myself, namely message distribution and update. The message system of cegui is too complicated. I have read some other open-source UIS, games, and none of them make messages half as complicated. Ultimate encapsulation, completely unified. I would like to give an example that I disagree with. Even if there is no efficiency requirement for MFC, messages are clearly divided into window messages and command messages, and Win32 messages are only distributed.

 

Cegui is a gray-often-gray-flowing B. It is designed to be gray-often-creative UI. If you want to learn the value, I will not hesitate to give it a high score. For the moment, I have not found any one that is more valuable than others. However, in commercial projects, I think we should weigh the advantages and disadvantages.

 

Let's make a preview. Next we will talk about the design of the UI window hierarchy. You are welcome to make a brick. Well, I think I should write the code details by the way. I have learned and take notes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.