Java Code Examples for com.badlogic.gdx.utils.IntMap

The following examples show how to use com.badlogic.gdx.utils.IntMap. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: talos   Source File: RandomInputModuleWrapper.java    License: Apache License 2.0 6 votes vote down vote up
protected void removeSlot(int slot, boolean isInput) {

        IntMap<Slot> list = module.getInputSlots();
        if(!isInput) {
            list = module.getOutputSlots();
        }
        //remove this slot from module
        for(int i = slot; i >= 0; i++) { // don't do this kids
            if(list.get(i+1) == null) {
                list.remove(i);
                break;
            }
            list.put(i,list.get(i+1));
            list.get(i).setIndex(i);
        }
        module.slotCount--;

        loadSlots();
    }
 
Example 2
Source Project: talos   Source File: InputModuleWrapper.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void configureSlots() {
    map = new IntMap<>();
    map.put(ScopePayload.EMITTER_ALPHA, "Emitter.alpha - Duration");
    map.put(ScopePayload.PARTICLE_ALPHA, "Particle.alpha - Lifetime");
    map.put(ScopePayload.EMITTER_ALPHA_AT_P_INIT, "Duration at particle init");
    map.put(ScopePayload.SECONDARY_SEED, "Primary Seed");
    map.put(ScopePayload.PARTICLE_SEED, "Secondary Seed");
    map.put(ScopePayload.PARTICLE_POSITION, "Particle position");
    map.put(ScopePayload.TOTAL_TIME, "Global Time");


    selectBox = addSelectBox(map.values());
    addOutputSlot("output", 0);


    selectBox.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            String selectedString = selectBox.getSelected();
            int key = map.findKey(selectedString, false, 0);

            module.setInput(key);
        }
    });
}
 
Example 3
Source Project: gdx-controllerutils   Source File: AndroidControllers.java    License: Apache License 2.0 6 votes vote down vote up
private void gatherControllers(boolean sendEvent) {
	// gather all joysticks and gamepads, remove any disconnected ones
	IntMap<AndroidController> removedControllers = new IntMap<AndroidController>();
	removedControllers.putAll(controllerMap);
	
	for(int deviceId: InputDevice.getDeviceIds()) {
		InputDevice device = InputDevice.getDevice(deviceId);
		AndroidController controller = controllerMap.get(deviceId);
		if(controller != null) {
			removedControllers.remove(deviceId);
		} else {
			addController(deviceId, sendEvent);
		}
	}
	
	for(Entry<AndroidController> entry: removedControllers.entries()) {
		removeController(entry.key);
	}
}
 
Example 4
Source Project: beatoraja   Source File: MainState.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void setSkin(Skin skin) {
	if (this.skin != null) {
		this.skin.dispose();
	}
	this.skin = skin;
	if (skin != null) {
		for (IntMap.Entry<Offset> e : skin.getOffset().entries()) {
			SkinOffset offset = main.getOffset(e.key);
			if(offset == null || e.value == null) {
				continue;
			}
			offset.x = e.value.x;
			offset.y = e.value.y;
			offset.w = e.value.w;
			offset.h = e.value.h;
			offset.r = e.value.r;
			offset.a = e.value.a;
		}
	}
}
 
Example 5
Source Project: talos   Source File: RandomInputModuleWrapper.java    License: Apache License 2.0 5 votes vote down vote up
private void loadSlots() {
    if(module != null) {
        leftWrapper.clearChildren();
        IntMap<Slot> list = module.getInputSlots();
        int tmpCount = list.size;
        module.slotCount = 0;
        for (int i = 0; i < tmpCount; i++) {
            module.slotCount++;
            addNewInputSlot();
        }

        invalidateHierarchy();
        pack();
    }
}
 
Example 6
Source Project: beatoraja   Source File: LR2SkinCSVLoader.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected S loadSkin(S skin, Path f, MainState state, SkinHeader header, IntIntMap option,
		ObjectMap<String, Object> property) throws IOException {
	this.skin = skin;
	this.state = state;
	for (String key : property.keys()) {
		if (property.get(key) != null) {
			if (property.get(key) instanceof Integer) {
				op.put((Integer) property.get(key), 1);
			}
			if (property.get(key) instanceof String) {
				for (CustomFile file : header.getCustomFiles()) {
					if (file.name.equals(key)) {
						filemap.put(file.path, (String) property.get(key));
						break;
					}
				}
			}
		}
	}

	IntMap<SkinConfig.Offset> offset = new IntMap<>();
	for (CustomOffset of : header.getCustomOffsets()) {
		final Object o = property.get(of.name);
		if(o instanceof Offset) {
			offset.put(of.id, (Offset)o);				
		}
	}
	skin.setOffset(offset);

	op.putAll(option);
	this.loadSkin0(skin, f, state, op);

	return skin;
}
 
Example 7
Source Project: riiablo   Source File: Animation.java    License: Apache License 2.0 5 votes vote down vote up
public boolean addAnimationListener(int frame, AnimationListener l) {
  Validate.isTrue(l != null, "l cannot be null");
  if (animationListeners == EMPTY_MAP) animationListeners = new IntMap<>(1);
  Array<AnimationListener> listeners = animationListeners.get(frame);
  if (listeners == null) animationListeners.put(frame, listeners = new Array<>(1));
  listeners.add(l);
  return true;
}
 
Example 8
Source Project: riiablo   Source File: KeyMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@NonNull
public Iterator<MappedKey> iterator() {
  IntMap.Values<ObjectSet<MappedKey>> entries = KEYS.values();
  ObjectSet<MappedKey> uniqueEntries = new ObjectSet<>();
  for (ObjectSet<MappedKey> entry : entries) {
    uniqueEntries.addAll(entry);
  }

  return uniqueEntries.iterator();
}
 
Example 9
Source Project: seventh   Source File: InputMap.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 */
public InputMap(ControllerInput controllerInput) {
    this.controllerInput = controllerInput;
    
    this.actions = new HashMap<String, InputMap.Action>();
    this.keymap = new IntMap<String>();
    this.buttonmap = new IntMap<String>();
    this.controllermap = new IntMap<String>();
    this.povButtons = new String[PovDirection.values().length];
    
    this.scroller = new String[2];
}
 
Example 10
Source Project: gdx-proto   Source File: Entity.java    License: Apache License 2.0 5 votes vote down vote up
public static void init() {
	list = new Array<>();
	destroyQueue = new Array<>();
	idMap = new IntMap<>();
	usedIDs = new Array<>();
	DynamicEntity.list = new Array<>();
	EntityModel.list = new Array<>();
}
 
Example 11
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
	for (IntMap.Entry<Touch> entry : pointers) {
		entry.value.update(screenX, screenY);
	}
	eventTouch.dispatch(null);
	return true;
}
 
Example 12
Source Project: talos   Source File: AbstractModule.java    License: Apache License 2.0 4 votes vote down vote up
public IntMap<Slot> getInputSlots() {
    return inputSlots;
}
 
Example 13
Source Project: talos   Source File: AbstractModule.java    License: Apache License 2.0 4 votes vote down vote up
public IntMap<Slot> getOutputSlots() {
    return outputSlots;
}
 
Example 14
Source Project: talos   Source File: TalosProject.java    License: Apache License 2.0 4 votes vote down vote up
public void loadProject (String data) {
	TalosMain.Instance().UIStage().PreviewWidget().getGLProfiler().reset();

	cleanData();

	projectSerializer.prereadhack(data);
	projectData = projectSerializer.read(data);
	readMetaData = projectData.metaData;

	ParticleEmitterWrapper firstEmitter = null;

	for(EmitterData emitterData: projectData.getEmitters()) {
		IntMap<ModuleWrapper> map = new IntMap<>();

		ParticleEmitterWrapper emitterWrapper = createNewEmitter(emitterData.name, emitterData.sortPosition);

		TalosMain.Instance().NodeStage().moduleBoardWidget.loadEmitterToBoard(emitterWrapper, emitterData);

		final ParticleEmitterDescriptor graph = emitterWrapper.getGraph();
		for (ModuleWrapper module : emitterData.modules) {
			map.put(module.getId(), module);

			graph.addModule(module.getModule());
			module.getModule().setModuleGraph(graph);
		}


		// time to load groups here
		for(GroupData group: emitterData.groups) {
			ObjectSet<ModuleWrapper> childWrappers = new ObjectSet<>();
			for(Integer id: group.modules) {
				if(map.get(id) != null) {
					childWrappers.add(map.get(id));
				}
			}
			ModuleWrapperGroup moduleWrapperGroup = TalosMain.Instance().NodeStage().moduleBoardWidget.createGroupForWrappers(childWrappers);
			Color clr = new Color();
			Color.abgr8888ToColor(clr, group.color);
			moduleWrapperGroup.setData(group.text, clr);
		}
	}

	sortEmitters();

	if(activeWrappers.size > 0) {
		firstEmitter = activeWrappers.first();
	}

	if(firstEmitter != null) {
		TalosMain.Instance().TalosProject().setCurrentEmitterWrapper(firstEmitter);
		TalosMain.Instance().NodeStage().moduleBoardWidget.setCurrentEmitter(firstEmitter);
	}

	TalosMain.Instance().UIStage().setEmitters(activeWrappers);
	TalosMain.Instance().NodeStage().getStage().setKeyboardFocus(null);
}
 
Example 15
Source Project: talos   Source File: ModuleWrapper.java    License: Apache License 2.0 4 votes vote down vote up
protected VisSelectBox addSelectBox(IntMap.Values<String> values) {
    return addSelectBox(values.toArray());
}
 
Example 16
Source Project: riiablo   Source File: Map.java    License: Apache License 2.0 4 votes vote down vote up
void putCell(int layer, int tx, int ty, DS1.Cell cell) {
  if (specials == EMPTY_INT_CELL_MAP) specials = new IntMap<>();
  specials.put(tileHashCode(layer, tx, ty), cell);
}
 
Example 17
Source Project: riiablo   Source File: Map.java    License: Apache License 2.0 4 votes vote down vote up
void copyWalls(Zone zone, int layer, int tx, int ty) {
  final int startTx = tx;
  final int startTy = ty;
  for (int l = 0; l < ds1.numWalls; l++, layer++, ty = startTy) {
    if (zone.tiles[layer] == null) zone.tiles[layer] = Zone.obtainTileArray(zone.tilesX * zone.tilesY);
    for (int y = 0; y < ds1.height; y++, ty++, tx = startTx) {
      int ptr = l + (y * ds1.wallLine);
      for (int x = 0; x < ds1.width; x++, tx++, ptr += ds1.numWalls) {
        DS1.Cell cell = ds1.walls[ptr];
        if (Orientation.isSpecial(cell.orientation)) {
          //DT1.Tile tile = zone.tiles[layer][zone.tileIndex(tx, ty)] = zone.dt1s.get(cell);
          if (ID.POPPADS.contains(cell.id)) {
            if (popPads == null) popPads = new IntMap<>();
            PopPad popPad = popPads.get(cell.id);
            if (popPad == null)
              popPads.put(cell.id, new PopPad(cell.id, x * DT1.Tile.SUBTILE_SIZE, y * DT1.Tile.SUBTILE_SIZE));
            else
              popPad.setEnd(
                  x * DT1.Tile.SUBTILE_SIZE + DT1.Tile.SUBTILE_SIZE + preset.PopPad,
                  y * DT1.Tile.SUBTILE_SIZE + DT1.Tile.SUBTILE_SIZE + preset.PopPad);
            zone.putCell(layer, tx, ty, cell);
          } else if (ID.WARPS.contains(cell.id) && cell.subIndex != 1) {
            //zone.addWarp(cell.id, tx, ty);
            zone.putCell(layer, tx, ty, cell);
          }
        }

        if ((cell.value & DS1.Cell.FLOOR_UNWALK_MASK) == 0) {
          continue;
        }

        if ((cell.value & DS1.Cell.HIDDEN_MASK) != 0) {
          // This seems like all the special tiles, null usually means marker tile (start pos),
          // non null usually means stuff like side of river, used for ?weather? ?rain drops?
          if (!Orientation.isSpecial(cell.orientation)) {
            // prints all of the debug tiles on side of river (any maybe elsewhere)
            //DT1.Tile tile = dt1s.get(cell);
            //System.out.println(x + ", " + y + " " + tile);
            or(zone, tx, ty, DT1.Tile.FLAG_BLOCK_WALK);
          } else {
            zone.putCell(layer, tx, ty, cell);
          }

          continue;
        }

        if (Orientation.isFloor(cell.orientation)) {
          continue;
        }

        // This tracks the blue river tiles that might be left for debugging
        // since they also appear in the ds1 editor this is based from,
        // I'll leave them in for now
        //if (cell.orientation == 1 && cell.mainIndex == 5 && cell.subIndex == 0) {
        //  System.out.println("found it! " + String.format("%08x", cell.value));
        //}

        DT1.Tile tile = zone.tiles[layer][zone.tileIndex(tx, ty)] = zone.dt1s.get(cell);
        or(zone, tx, ty, tile);

        // Special case, because LEFT_NORTH_CORNER_WALL don't seem to exist, but they contain
        // collision data for RIGHT_NORTH_CORNER_WALL, ORing the data just in case some
        // RIGHT_NORTH_CORNER_WALL actually does anything
        if (cell.orientation == Orientation.RIGHT_NORTH_CORNER_WALL) {
          DT1.Tile sibling = zone.dt1s.get(Orientation.LEFT_NORTH_CORNER_WALL, cell.mainIndex, cell.subIndex);
          or(zone, tx, ty, sibling);
        }
      }
    }
  }
}
 
Example 18
Source Project: riiablo   Source File: PropertyList.java    License: Apache License 2.0 4 votes vote down vote up
public void deepCopy(PropertyList src) {
  for (IntMap.Entry<Stat> entry : src.props.entries()) {
    props.put(entry.key, entry.value.copy());
  }
}
 
Example 19
Source Project: riiablo   Source File: Runes.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void init() {
  /**
   * Runeword95 requires some custom code because there is a duplicate, and the indexing method
   * will not ignore the duplicate, but my code does because the hashmap will only return one of
   * the values. The map will not overwrite the subsequent duplicates, which isn't a problem for
   * at least this case, but duplicates should be indexed incrementally.
   *
   * Additionally, due to current method of iteration, 170 is max runeword ID -- Runeword170, but
   * this is more than the actual number of runewords in the list, so must be manually punched in.
   *
   * Long story short, below works fine, but it's some rocky code that any internal modifications
   * will seriously fuck up. Actually fixing it will require some API changes to how excel works.
   * Also, none of this solves delirium which is marked as ID 2718 and not 48
   */
  IntMap<Entry> remap = new IntMap<>();
  for (int i = 1, j = offset() + 1; i < 171; i++) {
    Entry entry = get("Runeword" + i);
    if (entry != null) {
      switch (i) {
        case 22: // Delirium
          if (DEBUG) Gdx.app.debug(TAG, entry + ":" + i + ":" + j);
          remap.put(2718, entry);
          j++;
          break;

        case 95: // Passion / Patience duplicate
          if (DEBUG) Gdx.app.debug(TAG, entry + ":" + i + ":" + j);
          remap.put(j, entry);
          j += 2;
          break;

        default:
          if (DEBUG) Gdx.app.debug(TAG, entry + ":" + i + ":" + j);
          remap.put(j, entry);
          j++;
      }
    } else {
      if (DEBUG) Gdx.app.debug(TAG, "skipping " + i + ":" + j);
    }
  }

  entries = remap;
  //id = offset() + NumberUtils.toInt(value.Name.substring(8), 0);
  //if (DEBUG) Gdx.app.debug(TAG, value + ":" + value.Name.substring(8) + ":" + id);
}
 
Example 20
Source Project: gdx-ai   Source File: MessageDispatcher.java    License: Apache License 2.0 4 votes vote down vote up
/** Creates a {@code MessageDispatcher} */
public MessageDispatcher () {
	this.queue = new PriorityQueue<Telegram>();
	this.msgListeners = new IntMap<Array<Telegraph>>();
	this.msgProviders = new IntMap<Array<TelegramProvider>>();
}