MCPcopy Create free account
hub / github.com/Var3D/var3dframe / setResources

Method setResources

core/src/core/java/var3d/net/center/VGame.java:243–270  ·  view source on GitHub ↗
(Class<T> resource)

Source from the content-addressed store, hash-verified

241 private Class resource;
242
243 public <T> void setResources(Class<T> resource) {
244 this.resource = resource;
245 if (bundle == null) {
246 bundle = new VBundle(var3dListener);
247 }
248 if (resource == null) return;
249 // 将多语言本地文本赋值到R文件,如果有的话
250 try {
251 @SuppressWarnings("rawtypes")
252 Class R_clazz = resource;
253 @SuppressWarnings("rawtypes")
254 Class innerClazz[] = R_clazz.getDeclaredClasses();
255 for (@SuppressWarnings("rawtypes") Class cls : innerClazz) {
256 String name = cls.getSimpleName();
257 if (name.equals("strings")) {
258 Field[] R_fields = cls.getDeclaredFields();
259 for (Field field : R_fields) {
260 if (field.getModifiers() == 9)// public
261 // static就等于9,不服就去吃屎
262 field.set(null, bundle.get(field.getName()));
263 }
264 break;
265 }
266 }
267 } catch (IllegalAccessException e) {
268 e.printStackTrace();
269 }
270 }
271
272 public String format(String vaule, Object... args) {
273 return bundle.formatVaule(vaule, args);

Callers 3

runMethod · 0.95
switchLanguageMethod · 0.95
initMethod · 0.80

Calls 4

setMethod · 0.80
equalsMethod · 0.45
getMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected